ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Any way to get exact resolved URL?

February 02, 2010 5:50pm

Subscribe [3]
  • #1 / Feb 02, 2010 5:50pm

    dmyers

    43 posts

    Is there any way to get the resolved url of a page and/or actual template group and template.

    for example I have main group and submission group

    in main I have test page and in submission I have a index page

    If I call / I get /main/index

    If I call /test I get /main/test

    If I call /submission in reality I get /submission/index

    BUT!! I can’t seem to find a function that turns the URL in the resolved path and/or template group and template page???? Everything pretty much ends up the shorter URL format

    HELP!

    DMyers

  • #2 / Feb 02, 2010 5:58pm

    Ingmar

    29245 posts

    By default, EE uses a URL structure of http://example.com/index.php/group/template/url_title. If you are not using this structure EE takes a guess at what you could have meant. http://example.com/index.php/foobar can refer to

    - The “foobar” template of the default template group: http://example.com/index.php/site/foobar/
    - The “index” template of the “foobar” group: http://example.com/index.php/foobar/index/
    - An url_title using the “index” template: : http://example.com/index.php/site/index/foobar

    It’s recommended that you always use that structure, preferably via built-in EE variables. That said, I am not aware of an easy way is to determine the “real” URL.

    See also this series of articles by Lisa.

  • #3 / Feb 02, 2010 7:03pm

    dmyers

    43 posts

    That’s all well and good but, as a EE plugin/module/extension developer it would be nice to figure out what EE is “doing and/or loading”

    That way my plugin/module/extension can act accordingly. Right now I am trying to read the URL and use $this->EE->functions->uri… but even that isn’t showing the resolved information. It’s pretty much showing what I can already figure out from the $_SERVER[‘URL…. stuff. It would be nice to figure out it was doing xyz with some accessible variables. For example template_group, template_page, page, site, etc…

    Does that make any sense?

  • #4 / Feb 02, 2010 7:39pm

    Adam Dorsey

    1439 posts

    Have you seen the Docs page on URI segments?

    If you could tell us a bit more about what you are trying to accomplish, that would help.

    The index template is almost never going to appear in the URL. The template_group it resides in will.

  • #5 / Feb 02, 2010 7:53pm

    dmyers

    43 posts

    What I am trying to do is dynamically load css & javascript depending on the template group and template name

    /template_group/template_name

    but since

    /foo/index

    can also be called with

    /foo and /foo/

    it was throwing me off because /foo looks like a template name in the /main (default) template group but it’s not.

    so instead loading a css file /foo/index.css it was trying to load /foo.css

    I don’t like using undocumented stuff because it can change at a later time but, that seems like the only way to make sure the “full” path is resolved? does that help?

    In CI I would use rsegments which would return the resolved segments after all routing etc… but that’s kinda high jacked in EE with the super controller

    It’s not that I want to see the group and page in the url but I want my code (plugin/extension/module) to know what’s going on under the hood.

  • #6 / Feb 02, 2010 8:53pm

    Adam Dorsey

    1439 posts

    I’m going to move this to “How to” so you can get access to the community. This isn’t an actual “Tech Support” issue, as EE is operating as intended.

    Thanks and Happy EE’ing!

  • #7 / Feb 02, 2010 9:01pm

    dmyers

    43 posts

    Sorry about that. As I am only using 2.0 at this time I wasn’t sure where to put it. Once I talk 2.0 everyone tells me I am on the wrong list.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases