NEW - Traverse Segments Plugin…
Posted: 07 June 2008 04:35 PM   [ Ignore ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6617
Joined  04-15-2006

Hiya,

Another very very quick plugin made in about a minute so hopefully it works as advertised wink

This one is for returning the value of a certain URI segment working from the end of the URI backwards.

Usage :

{exp:traverse_segments position="0"}
{segment}
{if
'{segment}' == "test"}
YAY
{
/if}
{
/exp:traverse_segments}

Parameters :

position=“0”
This will retrieve the last segment

position=“1”
This would retrieve the last but one segment and so on and so forth!

Variables :
{segment}
Returns the value of the requested segment

Possibilities :

{if '{segment}' == "tests"}
<p>Segment was the same!!</p>
{/if}


Disclaimer - Not too sure if the if conditional above is entirely the correct way to do things. I mean with the ‘{segment}’ part. I think there is probably a better way to do this but it should work as is. Spitting out the {segment} variable should work without any problems though.


If the segment you had requested was in this case equal to tests then the message would be returned


Hope this is of some use to people. Hopefully it will work correctly on all systems too because as I said this was created very very quickly wink

Best wishes,

Mark

File Attachments
pi.traverse_segments.zip  (File Size: 2KB - Downloads: 106)
 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 07 June 2008 05:17 PM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  173
Joined  07-16-2005

This was working before the name change, but now it’s spitting the {segment} out at the very top of my template instead of where I specify it in the template code.

 Signature 

///////////////////////////////////////////////////////////////////////

+ Travis Schmeisser

nGen Works

+ rockthenroll

///////////////////////////////////////////////////////////////////////

Structure: a new way to build ExpressionEngine sites

Profile
 
 
Posted: 07 June 2008 05:20 PM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6617
Joined  04-15-2006

Hi Travis,

Sorry about the name change. Check that you changed the code for the usage on this plugin to this :

{exp:traverse_segments position="0"}
{segment}
{if
'{segment}' == "test"}
YAY
{
/if}
{
/exp:traverse_segments}

That should hopefully work for you?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 07 June 2008 05:20 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  173
Joined  07-16-2005

Also, if I use multiple instances I get an error:

Notice: Undefined offset: -1 in F:\inetpub\vhosts\domain-here.com\httpdocs\ee\plugins\pi.traverse_segments.php on line 45

 Signature 

///////////////////////////////////////////////////////////////////////

+ Travis Schmeisser

nGen Works

+ rockthenroll

///////////////////////////////////////////////////////////////////////

Structure: a new way to build ExpressionEngine sites

Profile
 
 
Posted: 07 June 2008 05:20 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  173
Joined  07-16-2005

I am using the new code including the new name…

 Signature 

///////////////////////////////////////////////////////////////////////

+ Travis Schmeisser

nGen Works

+ rockthenroll

///////////////////////////////////////////////////////////////////////

Structure: a new way to build ExpressionEngine sites

Profile
 
 
Posted: 07 June 2008 05:21 PM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6617
Joined  04-15-2006

Also ensure you download the plugin again from the top of this thread and install it and delete the old one?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 07 June 2008 05:23 PM   [ Ignore ]   [ # 6 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6617
Joined  04-15-2006
rockthenroll - 07 June 2008 05:20 PM

Also, if I use multiple instances I get an error:

Notice: Undefined offset: -1 in F:\inetpub\vhosts\domain-here.com\httpdocs\ee\plugins\pi.traverse_segments.php on line 45

Just tried here with multiple instances on the new plugin and all seems to be okay. Hopefully it is now working for you with the new plugin and code?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 07 June 2008 05:30 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  173
Joined  07-16-2005

Ok, new copy of the plugin fixed functionality.

Still getting this error (only when logged in though):

Notice: Undefined offset: -1 in F:\inetpub\vhosts\phdmc.controlpanel2.donet.com\httpdocs\ee\plugins\pi.traverse_segments.php on line 46

Notice: Undefined offset: -2 in F:\inetpub\vhosts\phdmc.controlpanel2.donet.com\httpdocs\ee\plugins\pi.traverse_segments.php on line 46

Could it be something weird with the hosting setup? I haven’t been able to get a few things working on it, like removing index.php and “force query strings” is on.

 Signature 

///////////////////////////////////////////////////////////////////////

+ Travis Schmeisser

nGen Works

+ rockthenroll

///////////////////////////////////////////////////////////////////////

Structure: a new way to build ExpressionEngine sites

Profile
 
 
Posted: 07 June 2008 05:37 PM   [ Ignore ]   [ # 8 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6617
Joined  04-15-2006
rockthenroll - 07 June 2008 05:30 PM

Could it be something weird with the hosting setup? I haven’t been able to get a few things working on it, like removing index.php and “force query strings” is on.

Possibly but as I said I did throw this together very very quickly so it may be something I did. Hopefully one of the moderators will see this thread and download and take a look at the plugin to see if I have done anything wrong.

Sorry that it is causing errors. None here on 4 sites I have tested it on. 2 localhost and 2 real world. Hopefully one of the moderators or one of the other programmers will pick up on anything I have done wrong though.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 07 June 2008 05:47 PM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  173
Joined  07-16-2005

No worries. It does work, just getting the errors. Thanks again!

 Signature 

///////////////////////////////////////////////////////////////////////

+ Travis Schmeisser

nGen Works

+ rockthenroll

///////////////////////////////////////////////////////////////////////

Structure: a new way to build ExpressionEngine sites

Profile
 
 
Posted: 07 June 2008 05:52 PM   [ Ignore ]   [ # 10 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6617
Joined  04-15-2006

No problems, well apart from the problems that is!

Hopefully someone will see if I have done something that might be throwing those errors though if indeed it isn’t anything to do with your server problems.

Hope it is still useful though.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

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 09:33 AM
Total Registered Members: 65102 Total Logged-in Users: 65
Total Topics: 82260 Total Anonymous Users: 34
Total Replies: 442096 Total Guests: 238
Total Posts: 524356    
Members ( View Memberlist )