Image instead of category name

Discuss PivotX 2.0.x themes here, and view themes that are available for download.

Re: Image instead of category name

Postby hansfn » Mon Dec 06, 2010 10:35 pm

Just some comments:

1) Instead of [[ category ]] use [[ $entry.category.0 ]] That will give you the (internal) name, which is safe for filename usage, and not the display name.

2) For the category list I would have used:
Code: Select all
<ul id="category_list">
[[ category_list format='<li class="%name%"><a href="%url%">%display%</a></li>' ignore='notused' ]]
</ul>

and the in a CSS file assign the images to "ul#category_list li.categoryname".
hansfn
Developer
 
Posts: 3280
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: Image instead of category name

Postby Kaj » Tue Dec 07, 2010 9:55 am

@Hansfn Where in the (frontpage?) code should I change [[category]] to [[$entry.category.0]]?

Umm... moderating .css is not in reach of my limited knowledge :shock: (-what are you doing on this forum then!?- uhh well...)

The new code Harm gave does change something, but not everything. Looks like it does not find the image-file.
Should I allocate the .jpgs, or rename them again?

Code: Select all
<!-- begin category list -->
           <div class="categories"></div>
<div class="categories-inner">
[[capture name=captureurl assign=catchurl]] [[pivotx_url]]includes[[/capture]]
<ul>
[[category_list format='<li><a href="%url%"><img src="$catchurl/timthumb.php?src=%name%.jpg&amp;w=50&amp;zc=1" title="%display%" alt="%display%" /></a></li>' ignore='notused']]
<a href="Twitter etcetera"</a>
</ul>
</div>
<div class="categories-bottom"></div>
        <!-- end category list -->
Kaj
 
Posts: 9
Joined: Thu Nov 25, 2010 10:24 am

Re: Image instead of category name

Postby hansfn » Tue Dec 07, 2010 10:13 am

Harm wants to use the catchurl variable to make things work for all cases, but since you have installed PivotX at the root I think it's better with KISS:

Code: Select all
<ul>
[[category_list format='<li><a href="%url%"><img src="/pivotx/includes/timthumb.php?src=%name%.jpg&amp;w=50&amp;zc=1" title="%display%" alt="%display%" /></a></li>' ignore='notused']]
</ul>

PS! Can we please just post the relevant code (like I did above) so it's easier to follow?

@Harm: To expand the $catchurl varaible you need to put it in backticks. That's why your code didn't work.
hansfn
Developer
 
Posts: 3280
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: Image instead of category name

Postby Harm10 » Tue Dec 07, 2010 1:00 pm

KISS = Keep It Simply Stupid ;)

Obviously Hans' coding is more straightforward. All this fiddling around to catch a variable. I said I tested but I overlooked the not replacing of the variable. It took me some more testing to find out why it didn't work when I placed the backticks.
And then I found it in the documentation! For the replacing to happen the full string has to be in " "! So the ' and " should be switched around:
Code: Select all
[[capture name=captureurl assign=catchurl]] [[pivotx_url]]includes[[/capture]]
<ul>
[[category_list format="<li><a href='%url%'><img src='`$catchurl`/timthumb.php?src=%name%.jpg&amp;w=50&amp;zc=1' title='%display%' alt='%display%' /></a></li>" ignore='notused']]
</ul>
But looking at the end result maybe hard coding the url bit is clearer..... :lol:
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Image instead of category name

Postby Kaj » Tue Dec 07, 2010 4:19 pm

Wow it works!

Thank you, Hans and Harm. HaHa.

The last thing, for now ;) What do I need to add to get the category-name after the image?

See the result at http://www.nieuweverhalen.nl, btw.

Code: Select all
 <!-- begin category list -->
           <div class="categories"></div>
<div class="categories-inner">
    <ul>
    [[category_list format='<li><a href="%url%"><img src="/pivotx/includes/timthumb.php?src=%name%.jpg&amp;w=50&amp;zc=1" title="%display%" alt="%display%" /></a></li>' ignore='notused']]
</ul>
</div>
<div class="categories-bottom"></div>
        <!-- end category list -->
Kaj
 
Posts: 9
Joined: Thu Nov 25, 2010 10:24 am

Re: Image instead of category name

Postby Harm10 » Tue Dec 07, 2010 4:48 pm

This is a PivotX forum not a HTML forum....... ;)
You have to read up on the general structure of HTML!
Instead of the normal name that was there in the initial sample you've replaced it now with a <img> tag.
You obviously can put more in the <a> tag so after the end of the img and before the end of the a (</a>) you can put text.
E.g. just put %display% there and it will be replaced by the display name of the category.
I am not supplying a sample right now because it is my experience that you learn more by just experimenting knowing that it should work with a small change...... :)
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Image instead of category name

Postby Kaj » Tue Dec 07, 2010 10:17 pm

Harm10 wrote:This is a PivotX forum not a HTML forum....... ;)
You have to read up on the general structure of HTML!


Um... okay I will try :) Never dared to use css and mor stuff like it on my simple pages.
Is it also OK if I just donate? ;)

Thanks for the lesson btw! :D
Kaj
 
Posts: 9
Joined: Thu Nov 25, 2010 10:24 am

Re: Image instead of category name

Postby Harm10 » Wed Dec 08, 2010 8:54 am

Donations are always welcome! But probably won't give you the right to pose any question that you like........ :lol:

Sent Kaj a mail to point out some HTML things....... ;)
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Previous

Return to 2.x Themes

Who is online

Users browsing this forum: No registered users and 2 guests

cron