Page 1 of 1

Optional properties for entry

Posted: Fri Aug 17, 2007 3:08 pm
by Martin
Hi folks.

I have some questions for the PHP wizards here.

I've just pimped out my blog (http://www.hastalasiesta.org) with some digg/reddit-buttons. I think it looks fairly nice, but I crave some advanced functionality. :)

Seing how not all of my posts are particularly digg-worthy (I can't imagine anyone digging an entry that is about me stubbing my toe or something.) I would really like to be able to choose whether or not the buttons are shown or not.

I've tried the custom fields but I have several issues with this method. First of these is that it breaks the digg/reddit count on the buttons. I use {entry.link} in the template to make sure the digg count is working well, but when I include the code with a custom field it goes back to zero.

Secondly, and less of a problem, is that with the custom fields it seems I'd have to paste the JS-code into the custom field every time, which is not really ideal.

To summarize my questions:
1. Could anyone help me make the Custom Fields method work properly with the digg and reddit counters?

2. Is there some method to make a custom field default to include the same piece of code whenever I choose to use it?

Below is the HTML/JS I currently have included in entries.tpl

Code: Select all

</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script><br /><br />
		<script>reddit_url="http://www.hastalasiesta.org{$entry.link}"</script>
		<script>reddit_title='{$entry.title}'</script>
		<script language="javascript" src="http://reddit.com/button.js?t=2"></script>
		<noscript>...</noscript>
		            </div>

Re: Optional properties for entry

Posted: Fri Aug 17, 2007 3:28 pm
by garvinhicking
Hi!

Hm, how does the HTML differ if you do not use entryproperties? Does the digg_url output look different? To me it looks alright!? It also displays 2 diggs on your second article, so that should be right?

Secondly, and less of a problem, is that with the custom fields it seems I'd have to paste the JS-code into the custom field every time, which is not really ideal.

You would proceed by addinng a customfield like "is_dig". Then you enter "yes", "yay", "do it!" or anything else into that customfield for your new entry. In your entries.tpl you would use this code:

Code: Select all

{if $entry.properties.ep_is_dig != ''}
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script><br /><br />
		<script>reddit_url="http://www.hastalasiesta.org{$entry.link}"</script>
		<script>reddit_title='{$entry.title}'</script>
		<script language="javascript" src="http://reddit.com/button.js?t=2"></script>
		<noscript>...</noscript>
Regards,
garvin

Posted: Fri Aug 17, 2007 5:22 pm
by Martin
I love you garv.
Whenever I come to Germany I'm buying you a plethora of beers.

Posted: Fri Aug 17, 2007 5:33 pm
by Martin
Oh shit!
I broke it!
Gaah.

EDIT: And fixed it again. It was just my unleetness in PHP/Smarty. You'll still get the beers Garv. :)