Page 1 of 1

How to get the cat_name

Posted: Sun 18. Jan 2004, 14:53
by hidiho
Hi All,

In order to only make one or two templates, but having different images on top of it when someone navigates (no: not the random image tag), i'm seeking for the following solution:

suppose your structure is like:
- home
- services
- products

you'll make a template. In the header part, i want to show an image when someone clicks on services and a different one when products is chosen. In order to do so, i thought that:
- creating an services.jpg
- placing it in the pictures directory (/picture)
- adjusting the front.func.inc.php that it looks for picture/services.jpg

does anyone knows how to do this?

regards & thanks in advance

hidiho

Posted: Sun 18. Jan 2004, 18:13
by Oliver Georgi
simply create 3 different templates - fast and easy thing ;-)

Posted: Sun 18. Jan 2004, 19:31
by hidiho
LOL Oliver :D

Do you think i would ask this one here just for fun? I've to create 7 main entries in 3 languages = 21 templates. That's why CMS is in place -> easy the job. I was just wondering if there is such a thing like a 'global' $content["acat_name"] or something like that i can use to make it replace a variable.

Anyway, i'll try figuring out how,....

regards

hidiho

Posted: Sun 18. Jan 2004, 20:58
by Oliver Georgi
Hm, there is - you can choose from frontend structure array - this is always read totally. And this array can be used in own {PHP:check_my_image.php} script. All you have to create in this external script is:

Code: Select all

// where [cat_id] and value = img number
$cat_top_img[10] = 1;
$cat_top_img[2] = 1;
$cat_top_img[5] = 1;
$cat_top_img[12] = 2;
$cat_top_img[3] = 2;
$cat_top_img[6] = 2;
...
switch($cat_top_img[$GLOBALS['content']['cat_id']]) {
  case 1: echo '<img src="my_image_1.gif" width="10" height="30">'; break;
  case 2: echo '<img src="my_image_2.gif" width="50" height="30">'; break;
...
  default: echo '<img src="my_default.gif" width="100" height="30">';
}


Posted: Sun 18. Jan 2004, 21:45
by hidiho
:D now i'm laughing

thank you oliver! :wink:

Posted: Sun 18. Jan 2004, 22:20
by Oliver Georgi
I have mixed a bit - the struct array is not neccessary for my code snippet.

But you can find the cat name in this array -

$content["struct"][cat_id][...
"acat_name"
"acat_info"
"acat_struct"
"acat_sort" ´
"acat_hidden"
"acat_regonly"
"acat_ssl"
"acat_template"...]

Posted: Mon 19. Jan 2004, 10:16
by hidiho
Again Oliver,

it works great. I use the code snippet, since it gives me more flexibility

thanks

hidiho

Posted: Mon 19. Jan 2004, 15:37
by hidiho
Now i use it for everything and make section specific layouts without creating 21 templates! :D it really works great

Posted: Mon 19. Jan 2004, 17:11
by frold
How do you use it.. I do not understand!! ; if you have time your are more then welcome to make an example!

Posted: Mon 19. Jan 2004, 17:36
by hidiho
Frold

suppose the following

you've a template with the header/main/left etc
your sitestructure is:

- home [id=1]
--- about us [id=2]
- services [id=3]
--- special services one [id=4]
- products [id=5]
--- computers [id=6]

you want the header to show the image services.gif when services (or it's sublevel) is clicked and products.gif when products (or its sublevel) is clicked.

now: create your images [home.gif, services.gif, products.gif]. Place them somewhere in a directory: for the example the directory picture/header is used:

create a php file, call it e.g. "show_image.php"

in the file write the following:

Code: Select all

<?php
$cat_top_img[1] = 1; //home
$cat_top_img[2] = 1; //about us
$cat_top_img[3] = 2; //services
$cat_top_img[4] = 2; //special services one
$cat_top_img[5] = 3; //products
$cat_top_img[6] = 3; //computers

switch($cat_top_img[$GLOBALS['content']['cat_id']]) { 
  case 1: echo '<img src="picture/header/home.gif" width="100" height="25" border="0">'; break;
  case 2: echo '<img src="picture/header/services.gif" width="100" height="25" border="0">'; break; 
  case 3: echo '<img src="picture/header/products.gif" width="100" height="25" border="0">'; break;
   default: echo '<img src="picture/header/home.gif" width="100" height="25">';
} 
?>
Explanation:
case 1; means when either home or about us is selected,
case 2 means when either services or special services one is selected etc

In your template, in the header section, place somewhere where you want it to, a {PHP:show_image.php}.

Now upload your show_image.php to the root directory (otherwise change the path in the {PHP: statement}. Reload your page and see what happens.

regards

hidiho

Posted: Mon 19. Jan 2004, 18:00
by pSouper
very nice too ;)

Posted: Mon 19. Jan 2004, 20:22
by frold
thanks... you are my man (suppose you are) :P

Posted: Wed 6. Apr 2005, 13:35
by kippi
Hi,
I think I'll need a help on this one:
Oliver Georgi wrote:I have mixed a bit - the struct array is not neccessary for my code snippet.

But you can find the cat name in this array -

$content["struct"][cat_id][...
"acat_name"
"acat_info"
"acat_struct"
"acat_sort" ´
"acat_hidden"
"acat_regonly"
"acat_ssl"
"acat_template"...]
It would be really nice if there were a possibility to use given aliases instead hard coded values in the php ... same actually applies for example to replacements tags: [ID 23]... is working, but something like [ID 'alias_value']... for a given article would be perfect.
Is this maybe already possible and I'm missing something ? Anyone able to point me in the right direction ?

Many thanks in advance,
kippi

Posted: Wed 6. Apr 2005, 22:34
by Oliver Georgi
not possible yet - I plan to integrate alias for articles too - but often it's not neccessary bacuse makes no sense to remember the mass of article's alias.

Oliver