Extended Properties for Entries: Custom Fields
Posted by Garvin Hicking in Development, Plugins
Comments (6)
Trackbacks (0)
As a response to a Feature Request from Karotte, I have just committed an enhancement to the entryproperties plugin to 0.9-beta3 of our SVN (which will hopefully be turned into a 0.9 final at the end of this month).
The plugin configuration has now been altered so that you can add a comma-separated list of custom fieldnames, which you can then fill in when creating an entry.
That means, you can create two custom fields called Listening and Playing (don't use whitespace or special characters for fieldnames). Create an entry, and fill in values for those two fields. Now edit your entries.tpl template and place the Smarty Codes
Now listening to: {$entry.properties.ep_Listening}
Now playing: {$entry.properties.ep_Playing}
anywhere you like inside the entry loop. Remember to prefix your property keyname with ep_. Then you'll see those fields at the place you configured. You can also add the usual Smarty markup to check if a variable is empty, and add some DIV or other tags to surround your output.
This brings Serendipity a bit closer to CMS-features, once again. :-)
(The SVN nightlies will be built tomorrow, containing the new patch. SVN checkouts contain the change already at this time - users familiar with SVN only need to fetch the plugins/ serendipity_event_entryproperties/ serendipity_event_entryproperties.php file)
Allerdings sollte man vielleicht darauf hinweisen, dass die entries.tpl die vielleicht bessere Datei zum einbinden des Smarty Codes ist, oder?
Vollkommen großartig wäre es überdies hinaus, wenn man dieses "CustomField" jetzt noch mit der Ausgabe eines externen Scripts (oder evtl. eines Plugins) verknüpfen könnte - dann bräuchte ich bei "Playing: ..."-Statements gar nicht mehr tippen. ;)
so long...
Rembrandt
Rembrandt asked, that it would be great if you could associate external plugins with the new CustomFields.
This is already possible! Your plugin can just hook into one of the events where entries are fetched ('entry_display' or 'frontend_display' or even 'frontend_entryproperties') and then just set your $eventData property index to what you want to be displayed later on.
However, this was already possible even before CustomFields got invented. You can add your very own plugin hooks easily into the entries.tpl template, like this:
{serendipity_hookPlugin hook="custom_now_playing" hookAll=true"}
Then just let your plugin to all the work. http://www.s9y.org/78.html describes this as well.
Regards,
Garvin
So I'll have a closer look to hooks and the "magical stuff" behind them.
so long...
Rembrandt
1) in the Extended properties for entries plugin page. i change customfield1 to "Now listening to;"
2) when i make a post i type in "NIrvana"
3) inside my entries.tpl file I place this "Now listening to: {$entry.properties.ep_Listening}"
and then {$entry.properties.ep_Listening} is replaced by NIrvana
Is this how it is supposed to work. the place where i enter the word NIrvana, does it take html or simple text.
The input field takes any HTML code.


