{CATNUM} Displays category number
{CATNUM} Displays category number
Hello everyone. I've been lurking for a while but finally registered.
I'm not so good with PHP yet, still studying. I've been trying to make a replacement tag to get the category number of the current page but as you may had guessed already, I've had no luck.
I wonder if one of you has already done so or could help me out to do one. I want it so that I can display a different image on the left navigation space depending on which category the person is. That way I won't have to make a template per category just to get this done. So it'd be something like
<img src="{CATNUM}.jpg" alt="{PAGETITLE}">
Thank you.
I'm not so good with PHP yet, still studying. I've been trying to make a replacement tag to get the category number of the current page but as you may had guessed already, I've had no luck.
I wonder if one of you has already done so or could help me out to do one. I want it so that I can display a different image on the left navigation space depending on which category the person is. That way I won't have to make a template per category just to get this done. So it'd be something like
<img src="{CATNUM}.jpg" alt="{PAGETITLE}">
Thank you.
Last edited by DavidNetk on Sat 15. Jan 2005, 20:05, edited 3 times in total.
Never mind, I just had to try harder
Never mind, I just had to try harder
I got it! Here it is:
The tag is:
{CATNUM}
And it will give a number
I got it! Here it is:
Code: Select all
// Display current category number - by David Quint
// include in include/inc_front/content.func.inc.php
if( ! (strpos($content["all"],'{CATNUM}')===false)) {
$content["all"] = str_replace('{CATNUM}', $content["cat_id"], $content["all"]);
}
//--------------------------------------------------------------
{CATNUM}
And it will give a number
Re: Never mind, I just had to try harder
helloDavidNetk wrote:Never mind, I just had to try harder
I got it! Here it is:
The tag is:Code: Select all
// Display current category number - by David Quint // include in include/inc_front/content.func.inc.php if( ! (strpos($content["all"],'{CATNUM}')===false)) { $content["all"] = str_replace('{CATNUM}', $content["cat_id"], $content["all"]); } //--------------------------------------------------------------
{CATNUM}
And it will give a number
maybe edit the code that i will be work in the frontent_render folder. so the people need not edit the source.
I think you can also get the structure level from the session variables. you can take a look at all that kind of stuff by creating a file or having in a php block :
That might help you so you don't even have to make replacement tag.
Code: Select all
echo "<pre>";
print_r($GLOBALS);
echo "</pre>";
Re: {CATNUM} Displays category number
hi dude, I posted a message about that a while ago in the "proud of your web site forum"DavidNetk wrote:I wonder if one of you has already done so or could help me out to do one. I want it so that I can display a different image on the left navigation space depending on which category the person is. That way I won't have to make a template per category just to get this done.
http://www.phpwcms.de/forum/viewtopic.p ... highlight=
everything explained about how I implemented a different image logo for each structure / category
fine i use a script by Jan212 for random images, but show images by level is also very nice.
Would it be possible to add a file format?
especially flash?
or does this no work with this code snippet?
Would it be possible to add a file format?
especially flash?
or does this no work with this code snippet?
Gruß/ regards cyrano
--------------------------------------------------------
templates -> http://www.128.weitzelmedia.de
planepix -> http://www.planepix.de
XING -> https://www.xing.com/profile/Thomas_Weitzel3
--------------------------------------------------------
templates -> http://www.128.weitzelmedia.de
planepix -> http://www.planepix.de
XING -> https://www.xing.com/profile/Thomas_Weitzel3
I guess the replacement tag should then look like this:
didn't test it but I hope it will work for you.
Code: Select all
$content["all"] = preg_replace('/\{CATNUM:(.*?)\}/ie', '$content["cat_id"].".$1"', $content["all"]);
usage: {CATNUM:jpg} => 0.jpg
{CATNUM:extemsion}
Re: {CATNUM} Displays category number
This one is great! Does the same thing mine does but without having to edit the source.erwanpia wrote:hi dude, I posted a message about that a while ago in the "proud of your web site forum"DavidNetk wrote:I wonder if one of you has already done so or could help me out to do one. I want it so that I can display a different image on the left navigation space depending on which category the person is. That way I won't have to make a template per category just to get this done.
http://www.phpwcms.de/forum/viewtopic.p ... highlight=
everything explained about how I implemented a different image logo for each structure / category
I did it that way because my knowledge of PHP is limited and just had to find something that worked. I didn't want to add ".jpg" to the tag because I thought it would limit its use. If I just leave it to category number the same tag can be used to display a ".swf",".gif",".png" or whatever
Thank you for the replies and examples everyone! It is greatly appreciated!
hmm david have a look at my code... simply create a file:
replacementtags.php in your frontent render folder and
add my code in there then you ill be able to include your
images with whatever extension you like by simply adding
the extension in the replacement tag... as I told you above..
AND YOU ABSOLUTELY DONT HAVE TO EDIT THE SOURCE CODE WHENEVER YOU USE THE FRONTEND_ RENDER / INIT FOLDER!
{CATNUM:EXTENSION}
Examples:
{CATNUM:jpg}
{CATNUM:txt}
{CATNUM:swf}
{CATNUM:gif}
{CATNUM:doc}
{CATNUM:pdf}
{CATNUM:png}
and so on...
You can define new functions in any file in your frontend_init folder and call them in any replacementtag or whatever code in any file in the frontend_render folder. In Both of these folders you can use predefined phpwcms functions (by including the proper files) and variables (without inclding any file)
replacementtags.php in your frontent render folder and
add my code in there then you ill be able to include your
images with whatever extension you like by simply adding
the extension in the replacement tag... as I told you above..
AND YOU ABSOLUTELY DONT HAVE TO EDIT THE SOURCE CODE WHENEVER YOU USE THE FRONTEND_ RENDER / INIT FOLDER!
{CATNUM:EXTENSION}
Examples:
{CATNUM:jpg}
{CATNUM:txt}
{CATNUM:swf}
{CATNUM:gif}
{CATNUM:doc}
{CATNUM:pdf}
{CATNUM:png}
and so on...
You can define new functions in any file in your frontend_init folder and call them in any replacementtag or whatever code in any file in the frontend_render folder. In Both of these folders you can use predefined phpwcms functions (by including the proper files) and variables (without inclding any file)
Oh that's awesome! Now I understand. Sorry for taking so long!brans wrote:hmm david have a look at my code... simply create a file:
replacementtags.php in your frontent render folder and
add my code in there then you ill be able to include your
images with whatever extension you like by simply adding
the extension in the replacement tag... as I told you above..
AND YOU ABSOLUTELY DONT HAVE TO EDIT THE SOURCE CODE WHENEVER YOU USE THE FRONTEND_ RENDER / INIT FOLDER!
{CATNUM:EXTENSION}
Examples:
{CATNUM:jpg}
{CATNUM:txt}
{CATNUM:swf}
{CATNUM:gif}
{CATNUM:doc}
{CATNUM:pdf}
{CATNUM:png}
and so on...
You can define new functions in any file in your frontend_init folder and call them in any replacementtag or whatever code in any file in the frontend_render folder. In Both of these folders you can use predefined phpwcms functions (by including the proper files) and variables (without inclding any file)
Yeah I'll do that, thank you again!