Changing xml feed icon via template

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Changing xml feed icon via template

Post by abdussamad »

Hello

I am designing a new theme for s9y. How do I change the xml feed icon automatically for the different color versions of the theme? Images for different colors are stored in different sub-directories of the templatename/img/ directory. Will I have to use php to copy the relevant image into the img/ dir or can I do this using the style sheet? If I have to copy the image using php (coupled with smarty) then can I assume that the template directory is writeable?

If I allow users of s9y 1.1 to change template colors using the admin UI then does it make the theme incompatible for use with older versions of s9y?

In the technical document "configuration of theme options" section "smarty way" the path to the stylesheets does not allow for a non-standard templates directory path. How do I insert the relevant stylesheet link allowing for custom template paths? In other words is there a .tpl file tag equivalent to {TEMPLATE_PATH} ?

Thanks
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Changing xml feed icon via template

Post by garvinhicking »

Hi!

Actually, this is not easily possible with the current syndication plugin, because that does not support templating.

What you could do is to emit a different CSS for the color theme version that styles the XML.gif image per color:

Code: Select all

/* RED.css */
.serendipity_syndication_plugin img {
 display: none;
}

.serendipity_syndication_plugin a {
  background-image: url(path/to/red_xml.gif);
  background-repeat: no-repeat;
}
So you'd disable the usual IMG emitted by the HTML and override it with a CSS declaration.
In other words is there a .tpl file tag equivalent to {TEMPLATE_PATH} ?
Yes, you can use {serendipity_getFile} to check for a file in your template path!

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Post by abdussamad »

Garvin how do I change the xml feed icon for the categories? In this case the icon has a seperate link. Trying to do this with the following css does not work:

Code: Select all

.container_serendipity_categories_plugin .serendipitySideBarContent a img
{
display:none;
}

.container_serendipity_categories_plugin .serendipitySideBarContent a {
background-image:url("{TEMPLATE_PATH}img/green/xml.gif");
background-position:top left;
background-repeat:no-repeat;
display:inline;

}
Are themes created for s9y1.1 compatible with older s9y versions? Doesn't serendipity_getFile intrepret {TEMPLATE_PATH} in style sheets?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm, that CSS should work. Do you have the URL where this code is so that I can look at it?
Are themes created for s9y1.1 compatible with older s9y versions? Doesn't serendipity_getFile intrepret {TEMPLATE_PATH} in style sheets?
Yes! S9y top goal is compatibility. The getFile smarty function has been in since the first smarty serendipity version, so you can use it everywhere.

You can use {$template} to get the name of the template that is currently active, though. So you could use

Code: Select all

<img src="{$serendipityBaseURL}templates/{$template}/img/icon.gif" />
for example. But this would then not check other template directories like "default" to search for an image, like the getfile function would do!

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Post by abdussamad »

I figured out how to style the xml icon. First I have to set the categories plugin to accept smarty templating then add a space inside the xml icon link like so

Code: Select all

<a class="serendipity_xml_icon" href="{$plugin_category.feedCategoryURL}"> <img src="{$category_image}" alt="XML" style="border: 0px" /></a>
This and some futzing arround with the css got it to work.
Yes! S9y top goal is compatibility. The getFile smarty function has been in since the first smarty serendipity version, so you can use it everywhere.
Just to make sure, I was referring to making a theme whose colors or other options can be changed using the administrator interface (not getfile ). Is such a theme compatible with pre s9y 1.1 versions?

Secondly, you know how we use {TEMPLATE_PATH} in the CSS stylesheet styles.css and s9y replaces this with the appropriate path before presenting it to the browser. Can this be done in stylesheets other than the default styles.css? That is stylesheets included based on user selected theme options in the admin interface.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
Just to make sure, I was referring to making a theme whose colors or other options can be changed using the administrator interface (not getfile ). Is such a theme compatible with pre s9y 1.1 versions?
Ah, okay, I misunderstood that. Yes, such a theme would be backward compatible, if your template uses the theme option variable array so that it falls back to some output if an array / value is not existing.

Since smarty is pretty forgiving about unsert variables for foreach and other calls, this shouldn't be a problem, yes.
Secondly, you know how we use {TEMPLATE_PATH} in the CSS stylesheet styles.css and s9y replaces this with the appropriate path before presenting it to the browser. Can this be done in stylesheets other than the default styles.css? That is stylesheets included based on user selected theme options in the admin interface.
No - TEMPLATE_PATH is replaced using the serendipity.css.php script. If you emit your custom CSS files, the template path cannot be replaced because that CSS is not looped through PHP.

However, if you include your CSS from your template file in the .tpl file via:

Code: Select all

<link rel="stylesheet" src="{$serendipityBaseURL}templates/{$template/css/custom.css" />
then you will be able to use url(../img/icon.gif) calls in your CSS. CSS calls take their relative URL from the directory they were called in, so you can use relative links there easily.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Post by abdussamad »

Thanks. I'll try the things you have suggested.
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

I'm doing something similar to what abdussamad is doing, so first of all thanks for saving me some work :)

I was wondering whether I have a full list of all plugins/features actually using the xml icon. You guys have mentioned categories and feeds in this thread, I know that freetag can use the xml icon, too.

Any other plugin left to cover?
Post Reply