Hi,
I would like to present to your attention a new plugin - Weblog URL.
This plugin allows you to find weblog url as specified in weblog preferences.
VARIABLES:
1) weblog_url - outputs weblog url as specified in Control Panel.
2) weblog_short_name - outputs short name of the weblog.
PARAMETERS:
1) entry_id - Optional. Allows you to specify entry_id.
2) on_failure - (any string which consists from characters legal for use in ExpressionEngine’s tag parameter
values). Optional. Allows you to specify what {exp:weblog_url} tag will output in case an entry
having specified entry_id does not exist or the weblog to which entry was posted does not have
weblog url specified in preferences.
If you leave entry_id parameter undefined, you must use {weblog_url:entry_id_start}{weblog_url:entry_id_end}
variable pair.
EXAMPLE OF USAGE:
If entry_id is e.g. 246 then you can use optionally either single tag as here
{exp:weblog_url entry_id="246"}
or variable {weblog_url} within {exp:weblog_url}{/exp:weblog_url} tag pair as here
{exp:weblog_url entry_id="246"}
{weblog_url}
{/exp:weblog_url}
Both will return weblog url as specified in weblog preferences.
You will use {exp:weblog_url}{/exp:weblog_url} tag pair in case there is a need for
parse=“inward” parameter.
You may also instead of specifying entry_id as parameter of {exp:weblog_url} to wrap it
with {weblog_url:entry_id_start}{weblog_url:entry_id_end} variable pair. For example the code
as this is possible:
{exp:weblog_url}
{exp:weblog:prev_entry entry_id="110" category="5"}
<a href="{weblog_url:entry_id_start}{entry_id}{weblog_url:entry_id_end}{url_title}">Previous page: {title}</a>
{/exp:weblog:prev_entry}
{/exp:weblog_url}
{exp:weblog_url}
{exp:weblog:next_entry entry_id="110" category="5"}
<a href="{weblog_url:entry_id_start}{entry_id}{weblog_url:entry_id_end}{url_title}">Next page: {title}</a>
{/exp:weblog:next_entry}
{/exp:weblog_url}
Conditionals are supported. You can write the code as this:
{exp:weblog_url entry_id="246"}
{if weblog_short_name=="my_weblog"}
{weblog_url}
{if:else}
{weblog_short_name}
{/if}
{/exp:weblog_url}
If entry having entry_id specified in parameters or specified using
{weblog_url:entry_id_start}{weblog_url:entry_id_end} variable pair using does not exist,
then {exp:weblog_url} tag by default will return nothing. In case ‘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 weblog url inside the output of {exp:weblog:prev_entry} and {exp:weblog:next_entry} tags. These tags does not allow to pull weblog url which is specified in weblog preferences. Instead you must use {path=template_group/template} variable. This is very constricting if previous/next entries belong to different weblogs and should be displayed using different templates.
Changelog:
- 1.1.1 // Bug fixed - PHP error being shown when neither variables weblog_url or weblog_short_name nor variable pair {weblog_url:entry_id_start}{weblog_url:entry_id_end} is used.
- 1.1 // Added support for conditionals. Added {weblog_short_name} variable.
- 1.0 // Initial release.
