We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19638
    • 39 Posts
    Hello everybody
    i am trying to use this default [*parent*] Template variable for navigation purpose :

    <link rel="up" href="[~[*parent*]~]">


    This <head> element is supposed to be used by iCab / Opera & Link Widget Firefox Add On to link to the hierarchical parent of a document.
    But i do not know how to deal with the "0" id :-/

    Let see an example
    My site (0)
    -News (2)
    --Today news (4)
    --Yesterday news (5)
    -Index (3)

    If we are in the page "Today news" or "Yesterday news" the link work perfectly and point to "News"
    But if we are in the page "News" or "Index" the link point to the "0" id document who did not exist.
    I know than as a workaround i can put all the hierachy under "Index" but if it solve the proble for "News" and similars it will not solve it for "Index" main document (who is suppose to point to itself).

    So
    - Is an another way to create the "parent" link who avoid the problem of the "0" document ?
    - is there a way to tell to the 0 document to redirect to the "main" page (Index in this case) ?

      • 11975
      • 2,542 Posts
      Hi,

      you could use PHx or create a snippet to check the value before making the url.
      If the value is equal to 0 then replace it with $modx->config[’site_start’]

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 7923
        • 4,213 Posts
        or create your own "parent" tv with @eval

        @EVAL $id = $modx->documentObject[’parent’]; if ($id == 0) { return $modx->config[’site_start’]; } else { return $id; }


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 19638
          • 39 Posts
          Thanks you two this work perfectly (i have choice the "@eval method"). Il will probably post my "head chunk" latter smiley