Page 1 of 1
How do I append characters to a variable in the ECHO command
Posted: Tue Aug 24, 2010 4:07 pm
by Cre8tor
I would like to use the ECHO command to use in a hyperlink. The code I have now is:
<a href="<[ECHO text="category.name"/]>">
This creates a link with the "category.name" variable but the .html extension is missing from the end so it doesn't go to any real page. So I want to append the characters: .html to appear after the category name so it actually goes to a .html page. Can someone help me with the code for that?
Re: How do I append characters to a variable in the ECHO com
Posted: Tue Aug 24, 2010 5:27 pm
by JakeJ
Try this:
Code: Select all
$text = 'www.url.com/';
<a href="<?php echo $text.'category.name/'; ?>">Your Text Here</a>
This will output: <a href="
www.url.com/category.name/">Your Text Here</a>
Re: How do I append characters to a variable in the ECHO com
Posted: Tue Aug 24, 2010 6:02 pm
by Cre8tor
I actually had a simple solution: <a href="
http://www.url.com/<[ECHO text="category.name"/]>.html">
I ran into another problem though - the <[ECHO text="category.name"/]> outputs the category name in the exact same case lettering that it was typed. For example, if "Travel" was a category name, the link would become
http://www.url.com/Travel.html instead of
http://www.url.com/travel.html (in lower case). This causes a problem because html pages appear to be case sensitive.
Is there a way to change the text in the echo command to be all lower case letters? If not in the echo command, is there any other way to reduce those letters to lower case for purpose of the link?
Re: How do I append characters to a variable in the ECHO com
Posted: Tue Aug 24, 2010 6:07 pm
by JakeJ
In php there is a command strtolower() that will do that for you.
Re: How do I append characters to a variable in the ECHO com
Posted: Tue Aug 24, 2010 6:11 pm
by Cre8tor
Ok, I tried: <a href="
http://www.url.com<[ECHO strtolower(text="category.name"/)]>.html"> but that did not work. What would be the proper syntax to apply the strtolower command to my particular case?
Re: How do I append characters to a variable in the ECHO com
Posted: Tue Aug 24, 2010 6:18 pm
by JakeJ
I'm a little confused about your method. I'm not seeing php code there. No $ for the variable etc.
Re: How do I append characters to a variable in the ECHO com
Posted: Tue Aug 24, 2010 6:25 pm
by Cre8tor
This is part of a much longer code generated from link building software. The category.name is actually a variable which is defined at an earlier stage. That's the reason why my line works without the $ symbol.
But to make this as simple as possible, how can I reduce that variable, category.name, to lower case letters for that line only?
Re: How do I append characters to a variable in the ECHO com
Posted: Tue Aug 24, 2010 6:56 pm
by JakeJ
Since I don't know your link building software I have no idea. It will probably have to be done before you pass the link to the link building stuff.
But if you run the variable through strtolower() BEFORE you pass it to the link building software it should work.
Re: How do I append characters to a variable in the ECHO com
Posted: Tue Aug 24, 2010 7:00 pm
by Cre8tor
What would be the command to make the variable, category.name, to appear in lower case letters? I tried: strtolower(category.name) just before the line but that didn't work.
Re: How do I append characters to a variable in the ECHO com
Posted: Tue Aug 24, 2010 7:38 pm
by JakeJ
It's only going to accept a valid php variable name or properly formatted string. So you'll have to do strtolower($variable_name). Or, in html mode <?php strtolower($variable_name); ?>
I don't know what else to tell you other than to try to convert the actual variable BEFORE it gets passed to your software at all, but i'm not sure if that's possible.