SmartyTags in Searchresults

Found a bug? Tell us!!
Post Reply
SirRobert
Regular
Posts: 38
Joined: Fri Oct 14, 2005 12:18 am

SmartyTags in Searchresults

Post by SirRobert »

Hello,

I'm using Smarty-Tags that I defined by myself in the config.php.inc directly in the content-area of my StaticPages (thus not in the .tpl file). This works fine.

But if I am searching for this page with the search form, it displays the Smarty-Tags simply as code "{my_smarty_tag}". I don't want that tag to be interpreted by smarty (because that would destroy the design of the search results), but I want that this tag to be not displayed at all. Is this possible in any way?

Best Regards,

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

Re: SmartyTags in Searchresults

Post by garvinhicking »

Hi!

Since Serendipity 1.0 you should have a $serendipity['view'] variable that gets assigned as smarty {$view} variable.

You can check if that variable is set to 'search', and only if it is not set to that display your smarty-tag.

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/
SirRobert
Regular
Posts: 38
Joined: Fri Oct 14, 2005 12:18 am

Post by SirRobert »

Hello Garvin,

thanks for your answear! I have searched the s9y .php files for the $serendipity['view'] variable and found it in the index.php. But I have to admit that I did not yet recognize what I have to do with the variable and where to find the smarty {$view} thing.

I'd be grateful for another little tip.

Greetings,

Robert
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

After reading what you want, I think this is going to get a little complicated. If your custom Smarty tag is not getting processed in the search results, there's not much we can do, regardless of what view it is.

It seems to me step 1 is getting your custom tag to process in the search results. I know this will mess up the layout, but we can fix it in step 2 by changing the tag's behavior depending on the view variable.

So, are you using something like the Category Templates plugin that could read a different config.inc.php depending on which page you're on? That would make things easy: just define the tag in the template used by the search page so the tag does nothing.

If not, we've got to go deeper. Get the tag parsing everywhere, then modify its code so that if $serendipity['view'] != 'frontpage' the tag does nothing.
Judebert
---
Website | Wishlist | PayPal
SirRobert
Regular
Posts: 38
Joined: Fri Oct 14, 2005 12:18 am

Post by SirRobert »

Hello Judebert!

Thank you for your thoughts - they made me come much closer to the actual problem. I have been testing on how I get the search-results to interpret the SmartyTags and on how to change the config for this site: It seemd pretty complex to me.

But then I found a very cheap (I hope not too cheap) resolution for this problem. I simply replace the Smarty-Tags in the searchresult with a regular expression. Thus, I injected this code:

Code: Select all

$content = preg_replace ('~\{[A-Za-z0-9\-\_]*\}~is',' ',$content);
in the serendipity_event_statigpage.php on the place where staticpages creates the searchresult. Works fine.

Best Regards,

Robert
Post Reply