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.
