Plugin:  Entry Id
Posted: 05 June 2008 05:24 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  195
Joined  02-02-2007

Hi,

I would like to present to your attention a new plugin: Entry Id.

It allows to find entry id of the entry which has characteristics specified in parameters of the {exp:entry_id} tag.

PARAMETERS:

1) weblog - Optional. Allows you to specify weblog name.

2) category - Optional. Allows you to specify category id number
(the id number of each category is displayed in the Control Panel).

3) url_title - Optional. Allows you to specify URL title of the entry.

4) on_failure - (any string which consists from characters legal for use in ExpressionEngine’s tag parameter
values). Optional. Allows you to specify what {exp:entry_id} tag will output in case an entry
which has characteristics specified in parameters of the {exp:entry_id} tag does not exist.

5) invalid_input - Optional. Accepts two values: “alert” and “silence”.
Default value is “silence”. If the value is “alert”, then in cases when some
parameter’s value is invalid plugin exits and PHP alert is being shown;
if the value is “silence”, then in cases when some parameter’s value
is invalid plugin finishes its work without any alert being shown.
Set this parameter to “alert” for development, and to “silence” - for deployment.

At least one out of “weblog”, “category” and “url_title” parameters must be defined.

EXAMPLE OF USAGE:

If your weblog name is “my_weblog”, your category id number is “5”,
and url_title of your entry is “my_entry”,
then you can use optionally either single tag as here

{exp:entry_id weblog="my_weblog" category="5" url_title="my_entry"}

or variable {entry_id_number} within {exp:entry_id}{/exp:entry_id} tag pair as here

{exp:entry_id weblog="my_weblog" category="5" url_title="my_entry"}
{entry_id_number}
{
/exp:entry_id}

Both will return entry id of the entry.

Variable {entry_id_number} within {exp:entry_id}{/exp:entry_id} tag pair is
more powerful because you can use it’s output as parameter of other tag. For such use
you must add parse="inward" parameter to {exp:entry_id} tag.

For example, code as this will work

{exp:entry_id weblog="my_weblog" url_title="my_entry" parse="inward"}
{exp
:weblog:prev_entry category="5" entry_id="{entry_id_number}"}<p><a href="{path=my_template_group/my_template}">Previous</a></p>{/exp:weblog:prev_entry}
{exp
:weblog:next_entry category="5" entry_id="{entry_id_number}"}<p><a href="{path=my_template_group/my_template}">Next</a></p>{/exp:weblog:next_entry}
{
/exp:entry_id}

If entry which belongs to weblog and/or is posted into category having id number and/or has url_title
as specified in parameters does not exist, then {exp:category_id} tag
by default will return nothing. If ‘on_failure’ parameter was defined, then, in such case
the tag will output what was specified as a value of this parameter.

Place this tag in any of your templates.

I have developed this plugin in order to be able to supply dynamically entry_id parameter for {exp:weblog:prev_entry} and {exp:weblog:next_entry} tags since these two tags cannot be used inside {exp:weblog:entries} tag.

Changelog:

- 1.1 // Added invalid_input parameter.
- 1.0 // Initial release.

File Attachments
pi.entry_id_v1.1.zip  (File Size: 3KB - Downloads: 14)
 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 26 August 2008 10:52 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  195
Joined  02-02-2007

Hi,

I have released a version 1.1 of Entry Id plugin.

In this release parameter “invalid_input” was added. This parameter accepts two values: “alert” and “silence”. Default value is “silence”. If the value is “alert”, then in cases when some parameter’s value is invalid plugin exits and PHP alert is being shown;
if the value is “silence”, then in cases when some parameter’s value
is invalid the plugin finishes its work without any alert being shown.
Set this parameter to “alert” for development, and to “silence” - for deployment.

Since the plugin does not do comprehensive validation of parameters’ values, you cannot be absolutely sure that in cases no alert was thrown the input was really valid.

You may ask, why parameter “invalid_input” was needed there already “on_failure” parameter being available. The answer is, these parameters have different purposes. Using parameter “invalid_input” you can specify what plugin should do in case it considers some parameter’s value being invalid; using parameter “on_failure” you can specify what plugin should do in case it considers all parameters’ values being valid, but has found nothing to output.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 10:33 AM
Total Registered Members: 61058 Total Logged-in Users: 19
Total Topics: 73867 Total Anonymous Users: 14
Total Replies: 398438 Total Guests: 470
Total Posts: 472305    
Members ( View Memberlist )
Newest Members:  tanjadebieSan2kakifemreSchottec2kmeenazterjinFuadgeorge_k_alliskhalidmhamood