Feed-Templates depending on the User-Agent?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Boris

Feed-Templates depending on the User-Agent?

Post by Boris »

Hi everyone,

is there any way to make the Newsfeeds dependent on the HTTP-User-Agent?

Background: there are a few certain user-agents to whom I don't want to deliver the complete entries, but only headlines and/or teaser-texts.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Feed-Templates depending on the User-Agent?

Post by garvinhicking »

Yes, you can do that.

Write up a config.inc.php for your template, set

Code: Select all

<?php
$serendipity['smarty']->assign('user_agent', $_SERVER['HTTP_USER_AGENT']);
then in your feed*.tpl template you can use

Code: Select all

{if $user_agent == 'XXX'}
...
{else}
{/if}
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/
Boris

Re: Feed-Templates depending on the User-Agent?

Post by Boris »

Great. That sounds really easy. Thank you.
Post Reply