Page 1 of 2

New RepTag: {SHOW_CAT_IMAGE}

Posted: Thu 6. Apr 2006, 21:43
by CPM
I needed this, so I searched in this Forum and put some pieces together... Maybe there is already something similar, I don't know, but maybe anyone is interested in it.

You can hardcode some structur_level_ids (<- hope you understand that) and it gives you an image on every page that is below that id.
I needed it for custom header images in different page_sublevels and did not want to do it with templates. Its hardcoded for now, but if someone wants to change it to variables I would be happy, maybe I will do it myself some time, but for now it does what I need.

Code: Select all

<?php

// REPLACEMENT TAG {SHOW_CAT_IMAGE}


$cur_toplevel_name = '';
$GLOBALS['nav_point_listing'] = get_breadcrumb($GLOBALS['content']["cat_id"], $GLOBALS['content']['struct']);
$imageoutput = '';

if(isset($GLOBALS['nav_point_listing']) && count($GLOBALS['nav_point_listing']) > 1) {
   reset($GLOBALS['nav_point_listing']);
   next($GLOBALS['nav_point_listing']);
   $cur_toplevel_id = html_specialchars($GLOBALS['content']['struct'][ intval(key($GLOBALS['nav_point_listing'])) ]['acat_id']);
}

switch($cur_toplevel_id) {
  case 1: $imageoutput = '<img src="img/header/1.jpg" alt="" border="0">'; break;
  case 10: $imageoutput = '<img src="img/header/2.jpg" alt="" border="0">'; break;
  case 17: $imageoutput = '<img src="img/header/3.jpg" alt="" border="0">'; break;
   default: $imageoutput = '<img src="img/header/1.jpg" alt="" border="0">';
}

$content['all'] = str_replace('{SHOW_CAT_IMAGE}', $imageoutput, $content['all']);


?>
Put it into an .php file (for example reptag_showcatimage.php) and drop that file to
\phpwcms_template\inc_script\frontend_render\

[/quote]

Posted: Thu 6. Apr 2006, 21:56
by Ben_Hook
Wow, That's cool.. I might be able to adapt that to use other things than images..

Posted: Fri 7. Apr 2006, 03:03
by frenzal
Thanks I needed something like this for a site im making. Same layout but different header images, now i dont need to use too many templates

Posted: Fri 7. Apr 2006, 23:55
by wingover
Hi,

I need a simular function for a site in february and made a replacement-tag.
I add some options to the tag for more global needs.
Normaly a image for every cat is shown and the image-name is the cat-alias. And you can set the start level, the level-depth and the option for a random-image. If you have a structure with a high level-depth, you can use one image for every level-tree, so you don´t have to make a image for every child-level. And if the random-option is set, the tag searches for images with the alias-name and a number at the end.

Maybe useful for some projects...
Here is the link to the thread:
http://www.phpwcms.de/forum/viewtopic.php?t=9899

Grüzli - Andi

Posted: Wed 26. Apr 2006, 21:05
by StudioZ
This is another awesome RT 8)
Very productive RTs and Mods year isn't it ? :wink:

Here's what I am looking for...
Wish I could use it to place an image as a table background...:roll:

Looking for a way to call it like this, using the RT call instead:
<table border="0" width="100%"
style="background-image:url{SHOW_CAT_IMAGE};
background-repeat:repeat-x,y; cellspacing="0" cellpadding="0">

Common used method:
<table border="0" width="100%"
style="background-image:url(img/mybackground01.gif);
background-repeat:repeat-x,y; cellspacing="0" cellpadding="0">

Any tip would be greatly appreciated...
:wink:

Cheers,

Posted: Wed 26. Apr 2006, 21:31
by CPM
Nothing is easier than that...
just notice the changes below...

Code: Select all

<?php

// REPLACEMENT TAG {SHOW_CAT_IMAGE}


$cur_toplevel_name = '';
$GLOBALS['nav_point_listing'] = get_breadcrumb($GLOBALS['content']["cat_id"], $GLOBALS['content']['struct']);
$imageoutput = '';

if(isset($GLOBALS['nav_point_listing']) && count($GLOBALS['nav_point_listing']) > 1) {
   reset($GLOBALS['nav_point_listing']);
   next($GLOBALS['nav_point_listing']);
   $cur_toplevel_id = html_specialchars($GLOBALS['content']['struct'][ intval(key($GLOBALS['nav_point_listing'])) ]['acat_id']);
}

switch($cur_toplevel_id) {
  case 1: $imageoutput = 'img/header/1.jpg'; break;
  case 10: $imageoutput = 'img/header/2.jpg'; break;
  case 17: $imageoutput = 'img/header/3.jpg'; break;
   default: $imageoutput = 'img/header/1.jpg';
}

$content['all'] = str_replace('{SHOW_CAT_IMAGE}', $imageoutput, $content['all']);


?> 

Posted: Wed 26. Apr 2006, 21:40
by update
Hi StudioZ

perhaps try this:

Code: Select all

<table style="background-image: url ({SHOW_CAT_IMAGE});".......

or even
<img src="{SHOW_CAT_IMAGE}">
in an "HTML" contentpart for instance.

or this one also
<a href="link-to-somewhere"><img src="{SHOW_CAT_IMAGE}" border="0"></a>
I tried to knit together an rt some months ago (similar one) and it did work this way - really ! :wink:
Why not this one too?

Greetings
claus

Posted: Wed 26. Apr 2006, 21:42
by CPM
Exactly... Use my second RepTag and then use

Code: Select all

<table style="background-image: url ({SHOW_CAT_IMAGE});"

Posted: Wed 26. Apr 2006, 22:19
by StudioZ
He He CPM and Claus :D
Thanks a bunch :wink:
Took CPM's modified RT, ajusted the table,'s white spaces
and now working like a charm !!!!

For the records: :lol:
I just had to take out the extra white spaces in the CSS styling here:
<table border="1" width="100%" cellspacing="0" cellpadding="0" style="background-image:url({SHOW_CAT_IMAGE});background-repeat:repeat-x,y;">

and then... went: POoOFf! Done. 8)

Another one of there Great RTs that I very much enjoy ! :D

Gratitude 8)

Posted: Wed 26. Apr 2006, 22:58
by update
:)
I will try this one too :!:

Re: New RepTag: {SHOW_CAT_IMAGE}

Posted: Wed 23. Apr 2008, 11:40
by defect
Hy, it is possible that it work for subpages too? How?

Greetings Chrischan

Re: New RepTag: {SHOW_CAT_IMAGE}

Posted: Wed 23. Apr 2008, 12:16
by flip-flop

Re: New RepTag: {SHOW_CAT_IMAGE}

Posted: Wed 23. Apr 2008, 12:29
by defect
Hmm hy fli flop,

thx for your reply but in my case i think it wont work.

i need header images for every menupoint and i placed it as a div background image because i have to add content via backend in this div. it works but not for subpages. ya know?

German: hy flip flop, ich nutze diese script damit ich navi abhängig ein hintergrund bild platzieren kann, hintergrundbild deswegen weil da noch content drüber kommt.

Greetz chrischan

Edit: habs jetzt damit gelöst: http://forum.phpwcms.org/viewtopic.php? ... me#p101580

Thanks ;)

Re: New RepTag: {SHOW_CAT_IMAGE}

Posted: Wed 23. Apr 2008, 13:13
by flip-flop
Hy, it is possible that it work for subpages too? How?
Can´t find any hint for using as a background image.
I don´t understand you.

For me it is working like a charme:

Template:

Code: Select all

<div class="top2" style="background: #FFFFFF url({SHOW_ID_IMAGE}) 0px 0px no-repeat;"> ..........</div>
rt_show_id_image.php

Code: Select all

// check which code should be returned
if($check_id >=0 && $check_id <= 1000) $check_id = 5;

  case 1: $imageoutput = '/picture/header/bild1.jpg'; break;
  case 2: $imageoutput = '/picture/header/bild2.jpg'; break;
  case 3: $imageoutput = '/picture/header/bild3.jpg'; break;
......

Re: New RepTag: {SHOW_CAT_IMAGE}

Posted: Wed 23. Apr 2008, 14:10
by defect
Template:

Code: Select all

<div id="head" style="background-image: url({PHP:scripts/header-image_switch.php});background-repeat: no-repeat;"></div>
Pepes Script:

Code: Select all

    <?php

    // + ---------------------------------------------------------------------------- +
    //    copyright 2004 :        Dipl.-Ing. Manfred Peperkorn - All rights reserved. |
    //    eMail:                  info[AT]webdesign-mp[DOT]de                         |
    //    Dateiname:              header-image_switch.php                             |
    //    Aufruf in der Vorlage:  {PHP:scripts/header-image_switch.php}               |
    //    --------------------------------------------------------------------------- |
    //    Es sind die Werte xxxx innerhalb der "case xxxx:" - Anweisung auszufuellen! |
    //    Das sind die CAT-IDs (Kategorie-Identifikations-Nummern) der Kategorien     |
    //      Die entsprechenden Zahlenwerte koennen unter ADMIN gefunden werden.       |
    //      Dazu mit der Maus über das dunkle Kästchen vor dem Kategorienamen fahren. |
    // + ---------------------------------------------------------------------------- +


    // 1. Pruefung der CAT-ID der aktuellen Kategorie (Seite)
    //    Danach Zuweisung von einzelnen Bildern  (oder Random-Bilder-Ordnern), entsprechend der "aktuellen" CAT-ID

    $check_id = $GLOBALS['content']['cat_id'];
    switch($check_id) {
    //
    // Nachfolgend werden die Zuordnungen festgelegt, fuer einzelne Kategorien (Seiten)
    // Es sind entweder Verweise auf Zufallsordner {RANDOM:...} oder auf einzelne Bilder {IMAGE:...} moeglich
    //
    case   1: echo 'picture/head5.jpg'; break;                        //   Bilderordner von Zufallsbildern
      case   16: echo 'picture/head6.jpg'; break; 
        case   20: echo 'picture/head3.jpg'; break; 
          case   19: echo 'picture/head4.jpg'; break;  

    //case  14: echo '{IMAGE:random-verein/Clubhaus-001-200.jpg}'; break;      //   Einzelbild Zuweisung
    //case  10: echo '{IMAGE:random-verein/Clubhaus-002-200.jpg}'; break;      //   Einzelbild Zuweisung
    //
    // Diese Liste kann natuerlich beliebig erweitert werden...



    // 2. Wenn keine "Einzelzuweisung" erfolgt ist, Pruefung der CAT-ID der jeweiligen "Haupt-Gruppe"
    //    Danach Zuweisung von einzelnen Bildern (oder Random-Bilder-Ordnern), entsprechend der "Haupt-Gruppen" CAT-ID

    default:
    while( $GLOBALS['content']['struct'][$check_id]['acat_struct'] > 0 ) {
       $check_id = $GLOBALS['content']['struct'][$check_id]['acat_struct'];
    }
    switch($check_id) {
    //
    //case 8888:   echo '{IMAGE:header/header_monitor.jpg}'; break;               // Muster fuer Einzelbild Zuweisung
    //case 9999:   echo '{RANDOM:picture/random_header-TITEL}'; break;            // Muster fuer Bilderordner von Zufallsbildern
    //

    //
    // Diese Liste kann natuerlich beliebig erweitert werden...



    // 3. Allen Kategorien, die bisher noch keine Zuornung erhalten haben, werden nachfolgend verknuepft

    default:
    //
    // Zuweisung entweder eines Default-Bildes
    //echo '{IMAGE:header/header_monitor01.jpg}';                                 // Einzelbild Zuweisung
    //
    // Oder - alternativ - eines Bilderordnerns zur Anzeige von Zufallsbildern
    echo 'picture/head2.jpg';break;                                // Bilderordner von Zufallsbildern

    }
    }

    ?>
Thats the way it works for me Like a Charme | really cool.
Greetz Chrischan