We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

weird string length issue

Development and Programming

Brian Litzinger's avatar
Brian Litzinger
693 posts
16 years ago
Brian Litzinger's avatar Brian Litzinger

I’m using the Structure module, and trying to print out the breadcrumbs. I don’t think this related to Structure though, seems more like a PHP issue. In the breadcrumbs method there is this:

$uri = trim($TMPL->fetch_param('uri'));
$uri = $uri ? $uri : $IN->URI;

If I send in the uri param as “/news/archive/” a var_dump on $uri reports a string length of 26 characters, but if I set the value of $uri to “/news/archive/” directly within the PHP, var_dump reports a string of 14 characters, which is true. The problem is the breadcrumb method doesn’t work when I use fetch_param because the string length is incorrect. It works if I manually set the value because it finds an exact character match of “/news/archive/” within the site_pages database field.

What could be going on in the TMPL class to add extra characters to the param?

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

Have you tried printing out $uri directly, not just its length? Are you sure it doesn’t include http:// and the domain name, say?

       
Brian Litzinger's avatar
Brian Litzinger
693 posts
16 years ago
Brian Litzinger's avatar Brian Litzinger

I’ve echo’d it and it prints out as “/news/archive/”. But var_dump shows the string length as 26, when it should be 14. I added trim() around it to see if it had any weird characters, but trim() didn’t change a thing.

       
Greg Aker's avatar
Greg Aker
6,022 posts
16 years ago
Greg Aker's avatar Greg Aker

what does the var_dump look like?

-greg

       
Brian Litzinger's avatar
Brian Litzinger
693 posts
about 16 years ago
Brian Litzinger's avatar Brian Litzinger
$uri = trim($TMPL->fetch_param('uri'));
$uri = $uri ? $uri : $IN->URI;
    
var_dump($uri);

Yields:

string(26) "/news/archive/"

This is in a 3rd party module, but that should’t make a difference, b/c this is normal EE code.

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
about 16 years ago
Robin Sowell's avatar Robin Sowell

weird. And I can’t replicate just plopping it into a plugin. What do you get with

var_dump($IN->URI);

And try it in a template w/php as well- just

<?php
global $IN;
var_dump($IN->URI); 
?>
       
Brian Litzinger's avatar
Brian Litzinger
693 posts
about 16 years ago
Brian Litzinger's avatar Brian Litzinger

Found out that it is encoding my forward slashes…

string(13) "/products"

If I remove slashes, it works just fine, but I need to be able to send in “/products/view/” as a URI string. Is there something in the admin area to change this behavior?

Since this occurs in a 3rd party module I just added $uri = str_replace(‘& #47;’, ‘/’, $uri); and it works fine. (without the space between & and # obviously).

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
about 16 years ago
Ingmar Greil's avatar Ingmar Greil
Is there something in the admin area to change this behavior?

No, I believe you might be running into a safety feature of EE here.

Since this occurs in a 3rd party module I just added $uri = str_replace(‘& #47;’, ‘/’, $uri); and it works fine. (without the space between & and # obviously).

I am glad to hear that. Let me move this thread to “Modules”.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.