How to get the cat_name

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
hidiho
Posts: 38
Joined: Wed 3. Dec 2003, 23:44

How to get the cat_name

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9907
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

simply create 3 different templates - fast and easy thing ;-)
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
hidiho
Posts: 38
Joined: Wed 3. Dec 2003, 23:44

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9907
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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">';
}

Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
hidiho
Posts: 38
Joined: Wed 3. Dec 2003, 23:44

Post by hidiho »

:D now i'm laughing

thank you oliver! :wink:
User avatar
Oliver Georgi
Site Admin
Posts: 9907
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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"...]
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
hidiho
Posts: 38
Joined: Wed 3. Dec 2003, 23:44

Post by hidiho »

Again Oliver,

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

thanks

hidiho
hidiho
Posts: 38
Joined: Wed 3. Dec 2003, 23:44

Post by hidiho »

Now i use it for everything and make section specific layouts without creating 21 templates! :D it really works great
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

How do you use it.. I do not understand!! ; if you have time your are more then welcome to make an example!
http://www.studmed.dk Portal for doctors and medical students in Denmark
hidiho
Posts: 38
Joined: Wed 3. Dec 2003, 23:44

Post 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
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

very nice too ;)
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

thanks... you are my man (suppose you are) :P
http://www.studmed.dk Portal for doctors and medical students in Denmark
kippi
Posts: 3
Joined: Mon 4. Apr 2005, 11:35

Post 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
sometime, I'll promise ...
User avatar
Oliver Georgi
Site Admin
Posts: 9907
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Post Reply