Difficulty displaying image in new sidebox module
Hi all,
I am trying to build a template sidebox that can be used to add several social style websites and personal blogs, that can be styled to suit different image sizes and layouts inside the sidebox.
I need to display an image that links to the site:
HTML Code:
<a href="social_site_url/social_site_ID" target="_blank" title=""><img src="social_site.jpg" width="" height="" alt="" id="" /></a>
The image is located in templates/MY_TEMPLATE/images
My coding of both the :dontgetit<a href=""> and the :dontgetit<img src=""> are not correct.
Where did I go wrong?
tpl_social_sidebox.php:
Code:
<?php
$content = '';
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent" id="socialSidebox">';
$content .= ?>'<a href="<?php FACEBOOK_URL . YOUR_FACEBOOK_NAME ?>" target="_blank" title="<?php FACEBOOK_TITLE ?>"><img src="<?php ($template->get_template_dir(DIR_WS_TEMPLATE, $current_page_base,'images'), FACEBOOK_IMAGE_NAME ?>" width='<?php FACEBOOK_IMAGE_WIDTH ?>' height='<?php FACEBOOK_IMAGE_HEIGHT ?>' alt='<?php FACEBOOK_ALT ?>' id='socialImages')" /></a>';
<?php
$content .= '</div>';
?>
Any help greatly appreciated,
Goshawk
Re: Difficulty displaying image in new sidebox module
You want to use "echo" to output the constants and data to HTML.
<?php FACEBOOK_URL . YOUR_FACEBOOK_NAME ?>
should be
<?php echo FACEBOOK_URL . YOUR_FACEBOOK_NAME ?>
Re: Difficulty displaying image in new sidebox module
Thanks for your reply, but I still have a syntax error.
Code:
$content .= '?><a href='<?php echo FACEBOOK_URL . YOUR_FACEBOOK_NAME ?>' target="_blank" title='<?php echo FACEBOOK_TITLE ?>'><img <?php ($template->get_template_dir(DIR_WS_TEMPLATE, $current_page_base,'images'), ?> src='<?php echo FACEBOOK_IMAGE_NAME ?>' width='<?php echo FACEBOOK_IMAGE_WIDTH ?>' height='<?php echo FACEBOOK_IMAGE_HEIGHT ?>' alt='<?php echo FACEBOOK_ALT ?>' id="socialImages" />" /></a><?php';
Re: Difficulty displaying image in new sidebox module
Yes, you do. You have used single quotes for both PHP code and some HTML code, and this is confusing things. I also missed the fact that you start with PHP in $content .= , and so need to change the way you output PHP data inside the link code.
PHP Code:
$content .= '<a href="' . FACEBOOK_URL . YOUR_FACEBOOK_NAME . '" target="_blank" title="' . FACEBOOK_TITLE . '"><img src="' . ($template->get_template_dir(DIR_WS_TEMPLATE, $current_page_base,'images'), FACEBOOK_IMAGE_NAME . '" width="' . FACEBOOK_IMAGE_WIDTH . '" height="' . FACEBOOK_IMAGE_HEIGHT . '" alt="' . FACEBOOK_ALT . '" id="socialImages" /></a>';
Not guaranteeing I got every bit here...
Re: Difficulty displaying image in new sidebox module
There are two basic ways to create HTML output in a PHP file, and you can't mix them without problems.
You can use complete HTML statements outside of <?php ?> tags, with variables inserted using <?php echo $whatever ?>. This will output each line of HTML to the browser immediately as it occurs in the file.
Or you can accumulate the HTML content in a variable like $content, and output the entire thing later using <?php echo $content;?>