New RepTag: {SHOW_CAT_IMAGE}

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
CPM
Posts: 11
Joined: Mon 17. Oct 2005, 12:18

New RepTag: {SHOW_CAT_IMAGE}

Post 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]
______________

Kitsunet
http://www.kitsunet.de
info@kitsunet.de
______________
Ben_Hook
Posts: 29
Joined: Sun 4. Dec 2005, 21:19

Post by Ben_Hook »

Wow, That's cool.. I might be able to adapt that to use other things than images..
Last edited by Ben_Hook on Mon 5. Jun 2006, 21:15, edited 1 time in total.
  • If i bore you to death, don't say i didn't warn you.
frenzal
Posts: 17
Joined: Fri 17. Mar 2006, 17:17
Location: Belgium
Contact:

Post 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
wingover
Posts: 58
Joined: Wed 13. Apr 2005, 13:18
Contact:

Post 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
---------------------------------------------------
Vol Libre - der Traum vom freien Fliegen
http://www.gleitschirm-taxi.de
Faszination Berge
http://www.mountain-panorama.com
---------------------------------------------------
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Post 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,
Last edited by StudioZ on Wed 26. Apr 2006, 22:24, edited 1 time in total.
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
CPM
Posts: 11
Joined: Mon 17. Oct 2005, 12:18

Post 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']);


?> 
______________

Kitsunet
http://www.kitsunet.de
info@kitsunet.de
______________
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Post 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
CPM
Posts: 11
Joined: Mon 17. Oct 2005, 12:18

Post by CPM »

Exactly... Use my second RepTag and then use

Code: Select all

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

Kitsunet
http://www.kitsunet.de
info@kitsunet.de
______________
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Post 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)
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Post by update »

:)
I will try this one too :!:
User avatar
defect
Posts: 95
Joined: Thu 27. Jan 2005, 17:17
Location: Rostock
Contact:

Re: New RepTag: {SHOW_CAT_IMAGE}

Post by defect »

Hy, it is possible that it work for subpages too? How?

Greetings Chrischan
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: New RepTag: {SHOW_CAT_IMAGE}

Post by flip-flop »

>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
User avatar
defect
Posts: 95
Joined: Thu 27. Jan 2005, 17:17
Location: Rostock
Contact:

Re: New RepTag: {SHOW_CAT_IMAGE}

Post 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 ;)
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: New RepTag: {SHOW_CAT_IMAGE}

Post 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;
......
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
User avatar
defect
Posts: 95
Joined: Thu 27. Jan 2005, 17:17
Location: Rostock
Contact:

Re: New RepTag: {SHOW_CAT_IMAGE}

Post 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
Post Reply