Optional properties for entry

Creating and modifying plugins.
Post Reply
User avatar
Martin
Regular
Posts: 90
Joined: Mon Sep 27, 2004 1:30 am
Location: Oslo
Contact:

Optional properties for entry

Post by Martin » Fri Aug 17, 2007 3:08 pm

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>

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Optional properties for entry

Post by garvinhicking » Fri Aug 17, 2007 3:28 pm

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
# 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/

User avatar
Martin
Regular
Posts: 90
Joined: Mon Sep 27, 2004 1:30 am
Location: Oslo
Contact:

Post by Martin » Fri Aug 17, 2007 5:22 pm

I love you garv.
Whenever I come to Germany I'm buying you a plethora of beers.

User avatar
Martin
Regular
Posts: 90
Joined: Mon Sep 27, 2004 1:30 am
Location: Oslo
Contact:

Post by Martin » Fri Aug 17, 2007 5:33 pm

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. :)

Post Reply