EllisLab text mark
Advanced Search
     
Plugin: Weblog URL
Posted: 10 June 2008 09:38 AM   [ Ignore ]
Avatar
Joined: 2007-02-02
981 posts

The attached add-on files may be out of date.  Please visit Devot-ee for the latest versions.

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.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 23 August 2008 09:58 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-09-05
35 posts

some of your files, including this, seem to be corrupt

 
Posted: 24 August 2008 01:56 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-02
981 posts

Hi odspi,

Just downloaded the plugin and it seems to be OK. That is, after unzipping I can see all code from beginning <?php to the ending ?>.

Try to download it using another browser and write if anything goes wrong.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 11 September 2008 06:57 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-02
981 posts

Hi,

I have released version 1.1 of Weblog URL plugin.

In this release support for conditionals was added.

Also a new variable - {weblog_short_name}, which outputs short name (not title) of the weblog was introduced.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 03 November 2008 10:37 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2008-01-21
15 posts

A great plugin, I am using it in tandem with your Entry Id plugin, and they have gotten me out of a huge pickle, so thank you!

However, I would say that you may wish to check your code as I get the following error if I use conditionals only:-

Warningstrpos() [function.strpos]: Empty delimiter in /usr/home/*snip*/system/plugins/pi.weblog_url.php on line 108 

You see, in my scenario I only want to evaluate the value of weblog_short_name rather than use it, e.g.

{exp:entry_id url_title="{segment_3}" parse="inward"}
    {exp
:weblog_url entry_id="{entry_id_number}"}
        {if weblog_short_name
=="myweblog"}
        <?php 
if ($lang!=""{
            
echo("<s.c.r.i.p.t. language=\"javascript\">location.href=\"/{segment_1}/{segment_2}/{segment_3}/lang/default/\"</s.c.r.i.p.t.>");
        
}
        ?>
        {if
:elseif weblog_short_name=="myweblog_de"}
        <?php 
if ($lang!="_de"{
            
echo("<s.c.r.i.p.t. language=\"javascript\">location.href=\"/{segment_1}/{segment_2}/{segment_3}/lang/_de/\"</s.c.r.i.p.t.>");
        
}
        ?>
        {if
:elseif weblog_short_name=="myweblog_it"}
        <?php 
if ($lang!="_it"{
            
echo("<s.c.r.i.p.t. language=\"javascript\">location.href=\"/{segment_1}/{segment_2}/{segment_3}/lang/_it/\"</s.c.r.i.p.t.>");
        
}
        ?>
        {
/if}
    {
/exp:weblog_url} 
{
/exp:entry_id} 

What I have done for now is include an extra if:elseif that will never apply with the {weblog_short_name} tag placed in it.

 
Posted: 04 November 2008 03:57 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-02
981 posts

Hi baboonbrand,

You spotted a bug.

I fixed it, so grab the version 1.1.1 using the link above and let me know if something goes wrong.

Many thanks for reporting.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 17 November 2008 10:51 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2008-01-21
15 posts

Sorry for the delay in getting back to this thread.  Problem now solved, thanks for the prompt response and fix Laisvunas!!

 
Posted: 07 January 2010 01:52 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Joined: 2007-06-06
187 posts

Would it be possible to use the weblog id instead of article id to get the details?

e.g.

{exp:weblog_url id="246"}{weblog_short_name}{/exp:weblog_url} 

Or better yet…

{exp:weblog_url:shortname id="246"
 
Posted: 08 January 2010 06:59 AM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-02
981 posts

Hi,

You can use exp:weblog:info tag.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number