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

    I have coded a small snippet that generates tabbed content from resources of the resource tree. The tab titles need links to divs with given IDs (I use jquery UI tabs).

    Additionally I had to install the small plugin "AnchorsAway" to make work anchors within pages. But this Plugin destroys my tabs, because the [tt]<a href="#tab-ui-2">..</a>[/tt] in the tab titles are all converted to full monolingual URLs. That’s why I need my own snippet to produce correct multilingual URLs, which I could do with (yams_doc) in chunks or in templates. But I can’t use that in a snippet. But how CAN I retrieve the correct URL in a snippet? I know, there must be a way smiley

    Thanks in advance
    Martin
      • 22851
      • 805 Posts
      Please try the following:

      1. Add the following code to the top of your snippet:
      include_once( $modx->config['site_path'] . 'assets/modules/yams/class/yams.class.inc.php' );
      $yams = YAMS::GetInstance();
      


      2. Call the snippet with the parameter [tt]&langid=`(yams_id)`[/tt] to get the correct language. You could add something like this to your snippet:
      /* $langid [ string ]
       * This parameter is compulsory.
       * The language id.
       * Specified as follows: &langid=`(yams_id)`
       */
      if ( ! isset($langid) || ! $yams->IsActiveLangId( $langid ) )
      {
        return '';
      }
      


      3. Get the full multilingual URL using [tt]$yams->ConstructResolvedURL( $langid, $id )[/tt], where [tt]$id[/tt] is the id of the document you want the URL to point to. It sounds like you’ll be pointing to the current document, so [tt]$id = $modx->documentIdentifier;[/tt] should do the trick.
        YAMS: Yet Another Multilingual Solution for MODx
        YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
        Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
        • 10313
        • 375 Posts
        Hi!

        Thank you very much for you fast answer, but unfortunately I get a fatal error:

        Fatal error: Call to private method YAMS::ConstructResolvedURL() from context ’DocumentParser’ in /homepages/42/d34935001/htdocs/kk/manager/includes/document.parser.class.inc.php(770) : eval()’d code on line 37

        As the method is private, I can’t access it.
          • 22851
          • 805 Posts
          Ahhh. I forgot. I made the method public in my development version, but it’s not yet in the latest released version. So you have two options:
          1. Grab the latest development version from SVN: svn://nashi.podzone.org/yams/trunk/yams
          2. Edit assets/modules/yams/class/yams.class.inc.php, find the ConstructResolvedURL method and replace private by public.
            YAMS: Yet Another Multilingual Solution for MODx
            YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
            Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
            • 10313
            • 375 Posts
            Strike! It works very fine now! I have chosen the second option. Brilliant.

            Thank you very much.