How to put {ANY_ALIAS_IMG} into header of template?

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
jo
Posts: 10
Joined: Tue 4. May 2004, 20:22
Location: Poland, Kraków
Contact:

How to put {ANY_ALIAS_IMG} into header of template?

Post by jo »

Hi all,
It is my first post and first question.

Is there a way to put dynamic image {placeholder/replacement} in the header part of template?

Let’s say if I go to url index.php?contact I will have image contact.jpg
displayed in header and if I go to index.php?any_alias I will see anyaliass.jpg in a header part of the page?
jo
Pappnase

Post by Pappnase »

hello

there are two ways! one you create for each its own template!
or you ask jan212 for his script! or you wait for the next release.*smile*
jo
Posts: 10
Joined: Tue 4. May 2004, 20:22
Location: Poland, Kraków
Contact:

Post by jo »

Pappnase wrote:hello

there are two ways! one you create for each its own template!
or you ask jan212 for his script! or you wait for the next release.*smile*
ye, the first one sounds good -- but why would I need a CMS for? :)

if anybody know the answer, please help.
What I need is just a {IMAGE:$alias} :lol:
jo
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

Hi Jo,m
here is a little code that will help you out for now. it is a bit sloppy as it is tied to the category_ID and NOT the alias: i will have a quick look later for the alias solution.

for this code you will new to....
create a dir in you img folder called 'cat_images' and place within all the images you require, these must be named the same as cat_image_(cat_id).gif (example: cat_images_1.gif)
then place this code where ever you would like, whether it be in the template or in an article.

Code: Select all

[PHP]echo "<img src=\"img/cat_images/"."cat_image_".$GLOBALS['content']['cat_id'].".gif\">";[/PHP]
some changes you may wish to make:
change this to any path you choose: "img/cat_images/"
change this to any prefix you choose: ."myFileNamePrefix".
change this to any .extension you choose: .gif

you may also change the code in various ways to create a link of the image, add ALT tags etc.
hope it helps.

ps: to have the image reflect the article_id instead of the cat_id you should do something like this...

Code: Select all

[PHP]echo "<img src=\"img/article_images/"."article_image_".$GLOBALS['content']['article_id'].".gif\">";[/PHP]
very simmiler ;)
Last edited by pSouper on Wed 5. May 2004, 12:31, edited 1 time in total.
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

Code: Select all

<?php 

switch($GLOBALS['content']['cat_id']) { 

 // BOF 1=Your cat with ID 1
case 1: echo '<img src="img/head/my_img_1.jpg" alt="alt">'; break; 
 // EOF 

 // BOF 2=Your cat with ID 2
case 2: echo '<img src="img/head/my_img_2.jpg" alt="alt">'; break; 
 // EOF 
// to be continued...

default:    echo '<img src="img/head/my_def_img.jpg" alt="alt">'; 

} 

?>
Desc:
case "cat_id_int":echo '<img src>'; break;

Save the code from the code block below uner a new file. place it in the inc_ext folder in a new folder and call it like

{PHP:include/inc_ext/myfolder/myexample.php}
Regards/ Grüsse/ Groetjes - JAN212
------------------------------------------------
null212 - Büro für Kommunikation und Design
------------------------------------------------
Lyrikfetzen des Tages
1. Ist der Quelltext auch valide fragt Herr Müller ganz perfide.
2. Wat is dat een lekker ding.
3. Wer Vision hat soll zum Arzt gehen.
------------------------------------------------
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

all clean a pretty jan ;)
Pappnase

Post by Pappnase »

yes jan is a good boy!*smile*

i had thios script in my site!
i had it also post! but i didn't can discribe it! :oops:
jo
Posts: 10
Joined: Tue 4. May 2004, 20:22
Location: Poland, Kraków
Contact:

Post by jo »

thx all of you for fast respond.
I’ll try jan212 coding, because of a default img.
jo
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

SORRY TO ALL - I WAS ILL LAST WEEK AND COULDN'T SUPPORT THE COMMUNITY - and was busy all the time too...
now i am back on the track - regards to oliver, pappnase, frold, psouper, jérôme, snobba and all others...
Regards/ Grüsse/ Groetjes - JAN212
------------------------------------------------
null212 - Büro für Kommunikation und Design
------------------------------------------------
Lyrikfetzen des Tages
1. Ist der Quelltext auch valide fragt Herr Müller ganz perfide.
2. Wat is dat een lekker ding.
3. Wer Vision hat soll zum Arzt gehen.
------------------------------------------------
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

Hi J,
phew! I can go to bed now, i have been up 24/7 covering you here :shock:

:D
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

hi p,

thx to you and nice sleep :wink: - 24/7 support - we should work together...

|°~-| RAZZRRRRRRRRRRR....
Regards/ Grüsse/ Groetjes - JAN212
------------------------------------------------
null212 - Büro für Kommunikation und Design
------------------------------------------------
Lyrikfetzen des Tages
1. Ist der Quelltext auch valide fragt Herr Müller ganz perfide.
2. Wat is dat een lekker ding.
3. Wer Vision hat soll zum Arzt gehen.
------------------------------------------------
Post Reply