Forum Moderators: coopster
I'm new to PHP and HTML - and tries hard to learn this.... I am now completely stuck with a coding-syntax problem.
In the website I'm editing (a Joomla-site), I am trying to change some of the layout. In one of the pages - there's a small vertical menu, where these menuitems are listed as hypertext-links (URL-clickable text).
Now, ONE of these menuitems is rather "special". It's a kind of "ON" / "OFF" menuitem - where it changes state when you click on it (from "On" to "Off", and "Off" to "On"). The menuitem shows either:
[Show Images]
or
[Hide Images]
I'm NOT the author of this webpage (or the PHP-code)- which makes it harder (for me) to change...
This is the ORIGINAL codeline for this item:
<a href="index.php?option=com_chordbase&Itemid=<?php echo $Itemid ?>&task=viewSong&song_id=<?php echo $song_id ?>&showChords=<?php echo $showChords == "no"?"yes":"no" ?>"><?php echo $showChords == "no"?"Show":"Hide" ?> Images</a> <br />
This code [u]works fine[/u] - but for me it's rather complicated to understand fully...
NOW - THE PROBLEM:
I'm working on changing the layout and look of the page - and want to change these "text"-menuitems with small image-items (png-format) instead. The other menuitems I managed to change - and they work.. :) . But this "boolean" menuitem I haven't been able to solve.
I am gonna use 2 different menu-images for this menuitem (on/off images). Here's the code for the image-references I'm using:
Image 1
<img src="<?php echo $mosConfig_live_site ?>/components/com_chordbase/images/Show_images.png" border="0"/>
Image 2
<img src="<?php echo $mosConfig_live_site ?>/components/com_chordbase/images/Show_images.png" border="0"/>
What I want - is to exchange the text "Show" and "Hide" in the first code-part on top here, and somehow use the code for "Image 1" and "Image 2" in there. So far - I haven't found a way that works...
Is this even possible?
Thanks in advance,
koda
If the condition is true, 'Show' will be echoed. If the condition is false, 'Hide' will be echoed. It is a shortcut way of saying this:
<?php
if($showChords == "no") {
echo "Show";
}
else {
echo "Hide";
}
So try breaking this up to understand it a little better:
<a href="index.php?option=com_chordbase&Itemid=<?php echo $Itemid ?>&task=viewSong&song_id=<?php echo $song_id ?>&showChords=<?php echo $showChords == "no"?"yes":"no" ?>">
<?php echo $showChords == "no"?"Show":"Hide" ?>
Images</a> <br />
Now replace the shortcut with its equivalent:
<a href="index.php?option=com_chordbase&Itemid=<?php echo $Itemid ?>&task=viewSong&song_id=<?php echo $song_id ?>&showChords=<?php echo $showChords == "no"?"yes":"no" ?>">
<?php
if($showChords == "no") {
echo "Show";
}
else {
echo "Hide";
}
Images</a> <br />
Now do you see where you can substitute your images?