How can I get Babel and WayFinder working with different contexts and unique startids? - modx

I am using MODX Revolution 2.5.6-pl. I have a multilingual site with several languages using Babel which is working as expected. However, for the navigation I have a startid, which relates to a container in my default (English) site.
The other languages will use the same template and therefore the same WF call. How can I modify the WF call so that I can provide unique startids for every language context? - Or do I need to create a unique WF call for every language?
This is my WF call:
[[Wayfinder?
&startId=`80`
&outerClass=`navigation__nav__list`
&innerClass=`navigation__nav__submenu`
&rowTpl=`navigationRows`
&rowIdPrefix=`nav__item`
&level=`3`
]]

wayfinder has an option: &startIdContext but does not appear to be documented (post your question in the modx forums) failing that you can set a context variable on ewach context & call wayfinder:
[[Wayfinder?
&startId=`[[++context_start_id]]`
&outerClass=`navigation__nav__list`
&innerClass=`navigation__nav__submenu`
&rowTpl=`navigationRows`
&rowIdPrefix=`nav__item`
&level=`3`
]]

Related

How to create multilanguage MODx website with unique articles in each language?

I need ti develop multilanguage webiste with (russian, english and kyrgyz languages), each article has version only in one language.
Can you please help me with questions:
1. how to create context for kyrgyz language? is it just put culturekey=kg?
2. how to translate oarts of chunks, i.e "comments" or buttons? do I need to create different chunks for new contexts? Or I simply save translation somewhere?
3. how to control which resources will be shown through pdoresources (getresources)? do I need to put id from all contexts?
4. for context web — pages has alias mywebsite.ru/category/article, but for "en" context — mywebsite.ru/en/INDEX/category/article. how to remove index? when i try to use link like mywebsite.ru/en/ — it shows 503 error. what can be the problem?
Thanks!
Create new context
Use lexicon entry. If you don't want to create a new namespace, just use core.
If you read the documentation, you can see the available parameters to define the parent, resources, or excluded resources to show.
You need to check your .htaccess and all friendly URL settings. 503 itself means unavailable site. Check your system settings, and search for site_status key. It should be "yes" for a running website.

What is the best practice for overriding strings in Orchard CMS?

I often have the situation where the wording of specific strings from various modules or core features needs to be changed for specific tenants & themes in Orchard CMS.
For example, I may have a client that prefers to have the shopping cart checkout button say "Checkout Now" rather than "Go to checkout" which is a string contained within a view in a shopping module.
I can simply override the razor view in my theme and change the string, however views often are quite complex, and it doesn't feel right overriding a view just to change one string.
Another approach I have tried is to define a po translation file within my theme to override the string from the module. This works because the strings in the module are defined using the T() syntax. However, I've noticed that as soon as I define an override for a string within my theme, this override effects all tenants, instead of just the one tenant that has this theme enabled. I'm inclined to think that translations within modules/themes should be ignored from tenants where they are not enabled.
So I'm left wondering what the best approach for this scenario is?
The localisation/po file approach would be ok if tenants ignored po files from themes that aren't enabled, but then again, it would be really nice if there was a module or feature in core that allowed you to specify string overrides via the admin interface. I guess it's more of a "rewording" task than a "translation" task.
The preferred way of doing this is through template overrides. If you don't want to do that, you can actually break shapes down, and delegate the rendering to smaller templates that are easier to override. This is done by simply refactoring the part of a template that you want to be able to override individually into a separate template. This post explains how to do that: http://weblogs.asp.net/bleroy/creating-shapes-on-the-fly
If you're not willing to do that, you can use this module to get strings from the database instead of po files: http://gallery.orchardproject.net/List/Modules/Orchard.Module.Q42.DbTranslations It should be possible to modify it to fit your sceanrio.

Adding new section in control panel of Liferay

I want to add a new section in control panel of liferay and within that section I want to have my custom-portlet. I did it using ext. However I want to do it with hook . Is it possible ?
I don't think it would be that easy with a hook, because of the following reasons:
You can't modify in a Hook - the class com.liferay.portal.util.PortletCategoryKeys which contains the keys for displaying the different sections. The different sections are hard-coded in this class in a String array ALL.
You can't modify the logic of PortalImpl#isControlPanelPortlet() which uses the PortletCategoryKeys#ALL to determine if the request in question is for a control panel portlet.
Then you also have another method which you can't modify with a Hook and is used extensively PortalImpl#getControlPanelCategory()
Doing it with a hook:
I have not tried this but I think if you need to do it with a hook you would have to change all those JSPs which make use of PortletCategoryKeys#ALL and the methods of PortalImpl as stated above, and provide your custom implementation for all these methods in the JSP.
I would really like to know how you implemented it with an EXT may be just the steps or the methods you have overridden. So that I can try to convert those in terms of a hook.
This is as far as my understanding goes. Hope this helps.
With the advent of Marketplace, ControlPanel has a new category named "Marketplace" and that section is introduced in a plugin. However, I never checked if 6.1 GA2 introduced a new section that this plugin just fills. Check the marketplace plugin if you can find a trace of this section implemented there.
On the other hand, nobody has yet named any section that definitely required a new section (though some have asked me how to solve the same problem). For this reason, you might want to re-think the requirement and choose one of the existing sections. If you don't, at least I'd be interested in the name and purpose of the new section - I might find a first one actually justifying this kind of implementation...

Client id of elements changes in sharepoint page? Why? When?

Client id of every element from the sharepoint page changes sometimes.
Can anybody please tell me why and on which instance it changes???
jQuery is fantastic! It makes client-side development faster and
countless plug-ins are available for just about every need. Using
jQuery with Asp.NET Web-Forms gets aggravating when dealing with
nested server controls. ClientID’s get appended when using ASP.NET
Master Pages. Objects in JavaScript tend to look like this:
ctl00_m_g_aaf13d41_fc78_40be_81d5_2f40e534844f_txtName
The difficulty of the issue above is that, in order to get the element txtName, It’s necessary to know the full “path”. It’s quite
aggravating to refer to get the object using the method below:
document.getElementByID('ctl00_m_g_aaf13d41_fc78_40be_81d5_2f40e534844f_txtName');
This becomes a big problem when developing server controls or web parts that may be used in a typical ASP.NET application or SharePoint.
You cannot hard-code the path above if you don’t know the full path of
the control.
Fortunately, there are a few ways to get around this. There are three, in particular, I will mention. The first is the jQuery
equivalent to the standard JavaScript method:
document.getElementById("<%=txtName.ClinetID%>");");
This can be done in jQuery by using:
$("#'<%=txtName.ClinetID%>");");
The second jQuery method does not require server tags. This method searches through all tags and looks for an element ending with the
specified text. The jQuery code for this method is shown below:
$("[id$='_txtName']");
There are, of course, drawbacks to both methods above. The first is fast, but requires server tags. It’s fast, but it just looks messy.
Also, it will not work with external script files. The second
alternative is clean, but it can be slow. As I said earlier, there are
several other alternatives, but these two are the ones I find myself
using the most.
The third registering Javascript in C# code behind.
Page.ClientScript.RegisterStartupScript(GetType(), "saveScript",
String.Format("function EnableSave( isDisabled )"+
"{{ var saveButton = document.getElementById(\"{0}\");"+
"saveButton.disabled=isDisabled;}}", btnSave.ClientID), true);
Do not forget to call this script after controls have been loaded, I mean after Controls.Add(); in CreateChildControls method while
developing webparts.
$('input[title="Name"]')
Look at the page source and get the value of the title property - works every time.
ListBox1.Attributes.Add("onmouseup",
"document.getElementById('" + base.ClientID + "_" + lbnFilter.ClientID + "').style.display='block';");

Encapsulating Logic in Pages using GEB and Cucumber

Using GEB I was using the Page Object Pattern to encapsulate information about the different pages statically.
I then refactored my GEB code to be used from a separate class so I could encapsulate common commands using method calls.
For example I would have a method login() which will call the appropriate GEB code to login to the website that I am testing. I would then have other common functions using method calls on a TestHelper class.
I wanted to move these common functions to the Pages that they act upon. For example a search page would have a search method, the login page would have the login method. This way I can build a library of pages which have all the common functionality on them for use across multiple GEB projects. Now to do this each page must have a handle on the geb.Browser therefore I would now have to instantiate each page in the test setup. By doing so I am no longer able to use the standard page object pattern.
to ReviewQueuePage
assert at(ReviewQueuePage)
The code above will throw a null pointer as the object is no longer able to be accessed in a static manner meaning I had to change the code to
go ReviewQueuePage.url
This removes all the functionality of using the class as a Page.
Does anyone have any solutions for encapsulating the data for each of the pages in way that it doesn't cause the pages to act differently.
This resource maybe of interest to you. http://adhockery.blogspot.com/2010/11/encapsulating-page-state-and-actions-in.html. It also has examples in git.
This also might be useful Passing state between pages when using geb & spock
I'm a bit confused. Are you looking for a way to share common code among multiple pages? This is the impression I get after reading your question several times, but I'm not quite sure. You mentioned "common functions". Well, common components can be encapsulated using Module objects. In each page that uses a common component, simply reference the module object in the page object.

Resources