We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22851
    • 805 Posts
    Quote from: charliez at Aug 05, 2009, 11:10 AM

    Does YAMS works with EVO 1.0? or only with 0.9.6.x?
    I’ve seen it running fine with Evo on someone else’s site already, but I haven’t set up an Evo test site myself yet (perhaps this weekend). There’s certainly no reason why it shouldn’t work with Evo (and if there are any problems then I’d like to fix them) - so please try it out.
      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.
      • 19209
      • 18 Posts
      My test setup (as of now) is Evolution 1.0.0 + YAMS 1.0.4a-rc3 and so far everything seems fine.

      I do have one question regarding the use of ManagerManager and "hiding" redundant fields while editing a resource. For example, I have English and French, and whenever I edit a page I have the 2 extra tabs at the top (one for English and one for French) both sets of inputs (en + fr) appear on both pages. Shouldn’t only the en fields appear on the English tab and only the fr fields appear on the French tab? I forgot to mention that I do have "Hide fields" selected for "Hide Redundant Fields" in the "Other Params" tab of YAMS.

      @PMS - Let me know if I understand how YAMS works properly, in the template we use [*content*] but there are TVs for [*content_en*] and [*content_fr*] ... the actual translated fields. Does YAMS hook into the parsing of the template and replace [*content*] with [*content_{lang}*] where {lang} is the active language? I ask this because as I said in my previous post I need to be able to translate META tags / keywords + description. One last thing could you give any insight on the possibility of translating the alias as well? I really need translated, SEO-friendly URLs.

      Thanks in advance,
      --mgbowman
        • 19209
        • 18 Posts
        Sorry for the redundant question - I didn’t quite read all of the new posts tongue

        Would you like some help with tackling the TODO list? This is a feature that I almost cannot do with out. One of the biggest issues I’ve had with choosing the right CMS is the way it allows content writers / translators to create / edit / delete documents in the backend with ease-of-use. So far with MODx + YAMS, I like what I see. If I can help with this feature (and use the manual keywords TV method for now) then I think my I18N requirements (both frontend + backend) will be satisifed and I’ll choose MODx + YAMS laugh

        Thanks in advance,
        --mgbowman

        @PMS - Just on a side note, I’m very proficient in a wide range of programming languages so have no fear (I have 10+ years of PHP experience).
          • 22851
          • 805 Posts
          Quote from: mgbowman at Aug 06, 2009, 03:12 AM

          I do have one question regarding the use of ManagerManager and "hiding" redundant fields while editing a resource. For example, I have English and French, and whenever I edit a page I have the 2 extra tabs at the top (one for English and one for French) both sets of inputs (en + fr) appear on both pages. Shouldn’t only the en fields appear on the English tab and only the fr fields appear on the French tab? I forgot to mention that I do have "Hide fields" selected for "Hide Redundant Fields" in the "Other Params" tab of YAMS.
          You’re right, you shouldn’t see both sets of fields on both tabs. I have never seen that before. Are you using the latest version of ManagerManager and do you have any custom rules specified in addition to the YAMS ones?

          Quote from: mgbowman at Aug 06, 2009, 03:12 AM

          @PMS - Let me know if I understand how YAMS works properly, in the template we use [*content*] but there are TVs for [*content_en*] and [*content_fr*] ... the actual translated fields. Does YAMS hook into the parsing of the template and replace [*content*] with [*content_{lang}*] where {lang} is the active language?

          Effectively yes. YAMS actually inserts constructs into your document that embed all language variants, [*content_en*], [*content_fr*]... (See the YAMS constructs tab in the module documentation for the kind of things it does behind the scenes.) It then sorts them all out so that you end up with one version of the template for each language, all embedded within a single template. Then, when a page it requested, only the correct language version is sent. It’s slightly complicated by issues of caching and YAMS placeholders - but that’s a reasonably accurate overview of what it does.

          Quote from: mgbowman at Aug 06, 2009, 03:12 AM

          One last thing could you give any insight on the possibility of translating the alias as well? I really need translated, SEO-friendly URLs.

          You’re not the first to ask. Please see this post for how this would be implemented.

          I’d like to retain responsibility for managing the YAMS core code for the moment. However, you can still help. The challenge, if you accept, is the following:

          • Manually create alias_en, alias_fr... template variables for each language and associate them with your multilingual documents using YAMS or whatever.
          • Edit your documents and give your language dependent aliases values.
          • Write a plugin active on the OnPageNotFound event called ResolveLanguageDependentAliases, say. If a page has not been found, it should a) strip out the filename from the $_GET[’q’] param and b) look up that filename in the template variable content database table using the MODx dbapi (documentation on the wiki and newer but less complete documentation on confluence) to determine the id of the page with which it is associated, if any.

          If you can do that, then you will have done most of the hard work for me. All that would be left is to integrate it with YAMS and I can take it from there.
            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.
            • 19209
            • 18 Posts
            Thanks for the quick response.

            Quote from: PMS at Aug 06, 2009, 05:04 AM
            You’re right, you shouldn’t see both sets of fields on both tabs. I have never seen that before. Are you using the latest version of ManagerManager and do you have any custom rules specified in addition to the YAMS ones?

            I’m running MODx v1.0.0 + ManagerManager v0.3.2 + YAMS 1.0.4a-rc3 and set it up exactly as described in the docs with no additional MM rules (other than the default ones shipped with MM).

            assets/plugins/managermanager/mm_rules.inc.php
            <?php
            
            // MM rules can go in here, instead of a chunk
            // If you copy them to a chunk, don't include the opening and closing PHP tags
            
            // ------------------------ INSERT YOUR RULES HERE --------------------
            // These are example rules -- replace them with your own
            // PHP *is* allowed
            
            require( $modx->config['base_path'] . 'assets/modules/yams/yams.mm_rules.inc.php' );
            
            // News editors role -- creating a variable makes it easier to manage if this changes in the future
            $news_role = '3';
            
            mm_hideFields('pagetitle,menutitle,link_attributes,template,menuindex,description,show_in_menu,which_editor,is_folder,is_richtext,log,searchable,cacheable,clear_cache', $news_role);
            mm_renameTab('settings', 'Publication settings', $news_role);	
            mm_synch_fields('pagetitle,menutitle,longtitle', $news_role);
            mm_renameField('longtitle','Headline', $news_role, '', 'This will be displayed at the top of each page');
            
            // News story template
            $news_tpl = '8';
            mm_createTab('Categories','HrCats', '', $news_tpl, '', '600');
            mm_moveFieldsToTab('updateImage1', 'general', '', $news_tpl);
            mm_changeFieldHelp('longtitle', 'The story\'s headline', '', $news_tpl);
            mm_changeFieldHelp('introtext', 'A short summary of the story', '', $news_tpl);
            mm_hideFields('menuindex,show_in_menu', '', $news_tpl);
            mm_changeFieldHelp('parent', 'To move this story to a different folder: Click this icon to activate, then choose a new folder in the tree on the left.', '', $news_tpl);
            
            
            // For everyone
            mm_default('pub_date');
            mm_renameField('introtext','Summary');
            mm_changeFieldHelp('alias', 'The URL that will be used to reach this story. Only numbers, letters and hyphens can be used');
            mm_widget_tags('blogTags'); // Give blog tag editing capabilities to the 'blogTags' TV
            mm_widget_colors('colour', '#666666'); // make a color selector widget for the 'colour' TV
            mm_widget_showimagetvs(); // Always give a preview of Image TVs
            
            // For everyone except administrators
            mm_hideFields('link_attributes', '!1');
            //mm_moveFieldsToTab('tvcolour', 'general');
            
            mm_default('richtext', 0);
            
            // ------------------------ END OF RULES --------------------
            
            ?>


            Regarding translatable URLs, I’m going to start digging through MODx + YAMS and see if I can figure it out based on what you’ve said. It’s an absolute must that I have this so I *will* figure it out smiley

            Thanks again for all your help,
            --mgbowman

            PS - In step 12 of the docs you use [[yams? ...]] as the snippet example but according to the docs we create the snippet using ’YAMS’ as the name - hence the snippet should be [[YAMS? ...]]

              • 22851
              • 805 Posts
              Quote from: mgbowman at Aug 06, 2009, 05:44 AM

              Quote from: PMS at Aug 06, 2009, 05:04 AM
              You’re right, you shouldn’t see both sets of fields on both tabs. I have never seen that before. Are you using the latest version of ManagerManager and do you have any custom rules specified in addition to the YAMS ones?

              I’m running MODx v1.0.0 + ManagerManager v0.3.2 + YAMS 1.0.4a-rc3 and set it up exactly as described in the docs with no additional MM rules (other than the default ones shipped with MM).

              assets/plugins/managermanager/mm_rules.inc.php
              Please try putting the YAMS rules at the end, or commenting out the default manager manager rules. (There’s no point manipulating document variable fields that you are subsequently going to hide anyway.)

              Quote from: mgbowman at Aug 06, 2009, 05:44 AM

              Regarding translatable URLs, I’m going to start digging through MODx + YAMS and see if I can figure it out based on what you’ve said. It’s an absolute must that I have this so I *will* figure it out smiley

              Great!

              Quote from: mgbowman at Aug 06, 2009, 05:44 AM

              PS - In step 12 of the docs you use [[yams? ...]] as the snippet example but according to the docs we create the snippet using ’YAMS’ as the name - hence the snippet should be [[YAMS? ...]]

              Yes. A documentation bug. Will fix straight away. Well spotted!
                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.
                • 19209
                • 18 Posts
                Quote from: PMS at Aug 06, 2009, 05:57 AM

                Please try putting the YAMS rules at the end, or commenting out the default manager manager rules. (There’s no point manipulating document variable fields that you are subsequently going to hide anyway.)

                I removed everything but the YAMS rules include - it had no affect.

                Quote from: PMS at Aug 06, 2009, 05:57 AM

                Yes. A documentation bug. Will fix straight away. Well spotted!

                Not a problem. Some people call me a nit-picky detail freak. I’ll keep you posted on my findings with the URLs and tell you if I spot anything else.

                Thanks again,
                --mgbowman
                  • 22851
                  • 805 Posts
                  Quote from: mgbowman at Aug 06, 2009, 06:08 AM

                  Quote from: PMS at Aug 06, 2009, 05:57 AM

                  Please try putting the YAMS rules at the end, or commenting out the default manager manager rules. (There’s no point manipulating document variable fields that you are subsequently going to hide anyway.)

                  I removed everything but the YAMS rules include - it had no affect.
                  Please can you try updating your ManagerManager to the latest version to see if that makes a difference? 0.3.2.1

                  Quote from: PMS at Aug 06, 2009, 05:57 AM

                  Some people call me a nit-picky detail freak.
                  When it comes to writing high quality software, that’s a compliment. Glad to receive any feedback you have, no matter how nit-picky.
                    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.
                    • 19209
                    • 18 Posts
                    Quote from: PMS at Aug 06, 2009, 07:25 AM

                    Please can you try updating your ManagerManager to the latest version to see if that makes a difference? 0.3.2.1

                    I’ll try that first thing in the morning.

                    Regarding the translated URLs, I have a very rough draft (which makes alot of assumptions) - I’m going to tweak it more tomorrow to check for FURLs and add recursive lookups (for multi-path aliases).

                    assets/modules/yams/yams-ux.plugin.inc.php
                    <?php
                    
                    require_once( dirname( __FILE__ ) . '/class/yams.class.inc.php' );
                    
                    $evt = &$modx->Event;
                    switch ($evt->name) {
                    	case 'OnPageNotFound':
                    		$yams = YAMS::GetInstance();
                    		$lang = $yams->GetCurrentLangId();
                    		$docId = $this->getDocumentIdentifier('alias');
                    		$this->db->connect();
                        	        $tv_table = $this->getFullTableName('site_tmplvars');
                    		$tvc_table = $this->getFullTableName('site_tmplvar_contentvalues');
                    		$sql = "SELECT tvc.contentid 
                    			FROM $tv_table tv, $tvc_table tvc 
                    			WHERE tv.name='alias_$lang' 
                    			AND tv.id = tvc.tmplvarid
                    			AND tvc.value = '$docId'";
                    		
                    		$result = $this->db->query($sql);
                    		$count = $this->recordCount($result);
                    		if ($count == 1) {
                    			$row = $this->fetchRow($result);
                    			$docId = $row['contentid'];
                    			$this->sendForward($docId);
                    			exit();
                    		}
                    }
                    
                    ?>


                    Will report back with my progress.
                    --mgbowman
                      • 22851
                      • 805 Posts
                      Yes! That’s the basic idea.

                      The more I think about this, the more evident it becomes that the acceptance, verification and creation of multi-language friendly alias paths is going to be quite involved. I suggest that to start with we only support language dependent friendly aliases, with no paths. If we can get that working, then the logic required to generalise it later is unlikely to break what we have already done.

                      Some hints:
                      1.
                      $lang = $yams->GetCurrentLangId();

                      At this stage, we wont know what the current language is. This is currently decided after the id of the document being requested had been determined by MODx. It’s normally necessary to know the id of the document first so that we can decide whether it is a multilingual document or not - and if it is, we can attempt to figure out the language from the URL. Clearly, in this case, if we do find a document, then we know that it should be a multilingual one - and we should put in a check for that. This also means that we will have to search in all alias_{lang} language variants, and if we find a match, that will tell us the intended language. You can use
                      $activeLangIds = $yams->GetActiveLangIds();

                      to get an array of active lang ids. So, you might want to break up your SQL into two steps. 1) Find the ids of the template variables with names of the form alias_{activeLangId}. 2) Search in the content of those template variables to find a match for the alias, and determine the docId and the active language.

                      2.
                      $docId = $this->getDocumentIdentifier('alias');

                      Better call it $alias or something like that. The OnPageNotFound event doesn’t get passed anything from MODx as far as I can see, so we’ll get the alias from $_GET[’q’]. If it’s got any forward slashes in it then we can just return since we wont initially be supporting friendly alias paths.
                        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.