We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46971
    • 33 Posts
    Hi all,

    i want to add a button with a migx-tv that build a anchor-link. The tv "button-url" gets the resource list of "sections" within the migx-tv. But now with the tpl-chunk that contains the part "<a href="#[[~[[+button-link]]]]" ..." i have the problem that the output is something like:

    base.de/modx/#sections/portfolio instead of "base.de/modx/#portfolio

    I could also use the "*alias" of the resources under sections if it would help more than using the id of the resource. Did the same with the wayfinder after help from this forum. Something like: "<a href="#[[+alias]]" could help me - but this does not work, too.

    Every resource under sections is a section/part of the main site "home" byusing getresource. Need help smiley


    Resource-tree
    Home
    Sections
    - Teaser
    - Portfolio
    - About 
    - Contact
    Site A
    Site B


    MigX Code
    [[!getImageList? 
    &tvname=`teaserbutton` 
    &tpl=`teaserbutton_tpl`
    &docid=`[[+id]]`
    ]]
    

    This question has been answered by multiple community members. See the first response.

    [ed. note: dsquare last edited this post 10 years, 10 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You can turn off Friendly Alias Paths in the System Settings. You can also use the Freeze URI field for the child resources in question.

      There is also a patch for preventing the inclusion of an unpublished parent's alias in the URL path. https://github.com/Qwarble/revolution/commit/df1902d5b68e02d760842c19f3a6e647f38ff6ab

      I seem to remember seeing something quite recently about a plugin to do something similar, I haven't been able to find any reference to it yet. [ed. note: sottwell last edited this post 10 years, 10 months ago.]
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
      • discuss.answer
        • 4172
        • 5,888 Posts
        with fastField or pdoTools installed, you can use fastField - tags to get the alias of a resource, if you have the id.
        So you can try:

        <a href="[[~[[*id]]]]#[[#[[+button-link]].alias]]">  


        and have the anchor:

        <div id="[[+alias]]"></div>
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 46971
          • 33 Posts
          Thank you both.

          Bruno, is there any possibility to get an output like "#portfolio" only - for the anchor-link onpage? Instead of "base.de/modx/#portfolio" for example. Because of the whole path, my smooth-scrolling js does not work for this link/button, and would prefer to change it within the cms instead of changing the js-file(s) wink

          Thanks again.
          • discuss.answer
            • 46971
            • 33 Posts
            Okay, i got it myself - hoping the code is correct.

            <a href="#[[#[[+button-link]].alias]]"

            and the output is, for example:
            <a href="#portfolio"


            Next, I need to read the fastField documentation.
            Thank you!