WebmasterSite.net: PHP scripts to enable your creativity
WSN Links PHP Directory Software
PHP Scripts Webmaster Links Support Forums

Register | Forgot Password

own folder graphic for each category

Version:
printPrint


own folder graphic for each category
frankbeckers
Experienced

Usergroup: Customer
Joined: Dec 20, 2007
Location: Germany
Total Topics: 23
Total Posts: 76
Posted 01/10/08 - 12:28 PM:
quote post
#1
Hi to all,

for those who wants to have a unique folder graphic for each category here is a little solution. If you replace in main.tpl

<!-- BEGIN CATSBODY -->
<!-- BEGIN REGULAR -->
<td {CATWIDTH} valign="top" class="category">
<img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder.gif" alt="" /> <a href="http://www.webmastersite.net/forums/{CATURL}" class="categoryname">{CATNAME}</a> ({CATNUMLINKS}) {CATHASNEW} {CATADMIN}<br />


with

<!-- BEGIN CATSBODY -->
<!-- BEGIN REGULAR -->
<td {CATWIDTH} valign="top" class="category">
<?php if (file_exists("{IMAGESPATH}/folder-{CATID}.gif")) { ?>
<img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder-{CATID}.gif" alt="{SITETITLE} - {CATNAME}" align="top" style="float:left; padding:0px 5px 0px 0px;">
<?php } else if (file_exists("{IMAGESPATH}/folder-{CATNAME}.gif")) { ?>
<img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder-{CATNAME}.gif" alt="{SITETITLE} - {CATNAME}" align="top" style="float:left; padding:0px 5px 0px 0px;">
<?php } else { ?>
<img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder.gif" alt="{SITETITLE} - {CATNAME}" align="top">
<?php } ?>
<a href="http://www.webmastersite.net/forums/{CATURL}" class="categoryname" title="{SITETITLE} - {CATNAME}">{CATNAME}</a> ({CATNUMLINKS}) {CATHASNEW} {CATADMIN}<br />


for each category there will be used a folder grafic with the name 'folder-{CATID}.gif' or 'folder-{CATNAME}.gif'. Only if this new picture files are not present, the orginal file 'folder.gif' will be used.

All extensions or questions to this little php coding are welcome.

If you want to see it working, i can post some links (only german sites, but for picture looking it will be okay wink ).

Regards,
Frank

Edited by Paul on 01/12/08 - 12:12 PM. Reason: added code tags, fixed paths

Naturheilkunde und Alternativmedizin - Das Portal für Ihre Gesundheit
Kochen Verzeichnis - Alles zum genießen, schlemmen und naschen
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6316
Posted 01/11/08 - 09:53 AM:
quote post
#2
What you posted will not work for 4.1, except by accident if you have leftovers from a 4.0 install not properly removed, since you had it looking for template-associated images instead of style-associated images. Fixed it for you.

Using {CATNAME} will break on non-trivial names... possibly on spaces, almost certainly on apostrophes and punctuation. Worth noting it'd be case-sensitive on *nix.

An alternate method would be a custom file field for categories.

Edited by Paul on 01/11/08 - 09:59 AM

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
frankbeckers
Experienced

Usergroup: Customer
Joined: Dec 20, 2007
Location: Germany
Total Topics: 23
Total Posts: 76
Posted 01/11/08 - 04:31 PM:
quote post
#3
Hi Paul,

thanx for your help. I thought the using of {TEMPLATESDIR} is okay cause downlevel compatibility. But now I know it was randomly correct.

But your fixed version doesn't work for me, cause {IMAGESURL} includes every time the full url and the php function file_exists does not honor 'remote' urls. So I strip down {IMAGESURL} to have a relative dir.


...
<?php if (file_exists("templates/".basename('{IMAGESURL}')."/folder-{CATID}.gif")) { ?>
<img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder-{CATID}.gif" alt="{SITETITLE} - {CATNAME}" align="top" style="float:left; padding:0px 5px 0px 0px;">
<?php } else if (file_exists("templates/".basename('{IMAGESURL}')."/folder-{CATNAME}.gif")) { ?>
<img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder-{CATNAME}.gif" alt="{SITETITLE} - {CATNAME}" align="top" style="float:left; padding:0px 5px 0px 0px;">
<?php } else { ?> <img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder.gif" alt="{SITETITLE} - {CATNAME}" align="top">
<?php } ?>
<a href="http://www.webmastersite.net/forums/{CATURL}" class="categoryname" title="{SITETITLE} - {CATNAME}">{CATNAME}</a> ({CATNUMLINKS}) {CATHASNEW} {CATADMIN}<br />
...


Regards,
Frank

Edited by frankbeckers on 01/11/08 - 04:37 PM

Naturheilkunde und Alternativmedizin - Das Portal für Ihre Gesundheit
Kochen Verzeichnis - Alles zum genießen, schlemmen und naschen
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6316
Posted 01/12/08 - 12:10 PM:
quote post
#4
Ah, forgot that. {IMAGESPATH} is the one for file paths.

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
frankbeckers
Experienced

Usergroup: Customer
Joined: Dec 20, 2007
Location: Germany
Total Topics: 23
Total Posts: 76
Posted 01/13/08 - 04:44 AM:
quote post
#5
Paul wrote:
Ah, forgot that. {IMAGESPATH} is the one for file paths.


That's what i'm searching for... but it is also not working, cause {IMAGEPATH} contains the full installation dir from my hoster. (like automatcly File Upload Path: is filled) and not the relativ images path.

thanx for help,
Frank


Naturheilkunde und Alternativmedizin - Das Portal für Ihre Gesundheit
Kochen Verzeichnis - Alles zum genießen, schlemmen und naschen
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6316
Posted 01/13/08 - 09:59 AM:
quote post
#6
Why would you need a relative path? file_exists works with absolute paths, unless it's some sort of safe_mode restriction I'm unaware of.

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
frankbeckers
Experienced

Usergroup: Customer
Joined: Dec 20, 2007
Location: Germany
Total Topics: 23
Total Posts: 76
Posted 01/13/08 - 11:31 AM:
quote post
#7
thanx, you are right. file_exists works also with absolute paths. Here is the corrected coding:

...
<?php if (file_exists("{IMAGESPATH}/folder/{CATID}.gif")) { ?>
<img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder/{CATID}.gif" alt="{SITETITLE} - {CATNAME}" align="top" style="float:left; padding:0px 5px 0px 0px;" />
<?php } else if (file_exists("{IMAGESPATH}/folder/{CATNAME}.gif")) { ?>
<img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder/{CATNAME}.gif" alt="{SITETITLE} - {CATNAME}" align="top" style="float:left; padding:0px 5px 0px 0px;" />
<?php } else { ?>
<img src="http://www.webmastersite.net/forums/{IMAGESURL}/folder/folder.gif" alt="{SITETITLE} - {CATNAME}" align="top" />
<?php } ?>
<a href="http://www.webmastersite.net/forums/{CATURL}" class="categoryname" title="{SITETITLE} - {CATNAME}">{CATNAME}</a>
...

Naturheilkunde und Alternativmedizin - Das Portal für Ihre Gesundheit
Kochen Verzeichnis - Alles zum genießen, schlemmen und naschen
Search thread for
Download thread as


You don't have permission to post.

Please login or register.

   
 
© 2008 Paul Knierim. All rights reserved.