Contexts question


(Alderman) #1

I am creating content in both English and Welsh as part of my Squiz evaluation (we are bound by law to provide content in both languages). This is working perfectly as far as the body content is concerned, however, in my design file I need to do a test in order to put out the banner text in the correct language (currently both English and Welsh content have English banner text). The contexts are using accept-language headers in the condition for the Welsh context.


Any help appreciated.


(Scott Hall) #2

Hey Jeff


There are a number of different way this can be done, but may require a little implementation science. I'll tap a few tech consultants on the shoulder and see if they can point you in the right direction.



FYI, contexts are not supported in EES (yet) but are high on the agenda for the next round of major features to be rolled out.



Cheers



Scotty


(Alderman) #3

Thanks for that Scotty.


(Alderman) #4

I also need to be able to tell the left nav code to pick up the context of the asset names - I can set English and Welsh asset names no problem but the menu always prints out the English asset name even when the body content is using the Welsh context.


(Scott Hall) #5

[quote]
I also need to be able to tell the left nav code to pick up the context of the asset names - I can set English and Welsh asset names no problem but the menu always prints out the English asset name even when the body content is using the Welsh context.

[/quote]

Hi Jeff

This one requires a slightly different keyword to be used to refer to the 'attribute' instead.



Sof if your left nav has something like this for where the links are generated…

    
    


Or a variation of that, as you may have A tags wrapped around the printed name.
Then you'll need to change your var to be...
    
    


Or short name if your using short name, so that would be..

    
    


I just double checked this on my end, using a GET var condition to switch between two contexts and works well.

Cheers

Scotty

(Scott Hall) #6

[quote]
I am creating content in both English and Welsh as part of my Squiz evaluation (we are bound by law to provide content in both languages). This is working perfectly as far as the body content is concerned, however, in my design file I need to do a test in order to put out the banner text in the correct language (currently both English and Welsh content have English banner text). The contexts are using accept-language headers in the condition for the Welsh context.



Any help appreciated.

[/quote]



Hi Jeff



If you can put your header markup in a standard page asset, and then nest that into the design file (using nested design area and bring it in through the design customisation) then this would be the easiest way (I think) to control multiple context for banners. That way you dont need to edit the design file at all, it comes down to manipulating the nested asset.



Cheers



Scotty


(Charlotte Westney) #7

Hi Jeffers,


We have a site running in Matrix in both English and Welsh: http://www.eryri-npa.gov.uk/

Feel free to take a look at the source code on Eng/Welsh pages to see all the bits that switch between the contexts; title tags, metadata tags, images, navigation, feedback forms etc.

As you say, everything has to be available in both languages, not just the body content!



If you have any specific questions about the site set-up, let me know.



All the best,

Charlie.


(Alderman) #8

Scotty and Charlie - that's great! many thanks and a lot for me to look at and play around with.


(Alderman) #9

Welsh menus all working now thanks using


[html]

<a href="<MySource_PRINT var='asset_url'/>"><MySource_PRINT var="asset_attribute_name"/></a>

[/html]



Now for the header replacement.


(Alderman) #10

[quote]
Hi Jeffers,



We have a site running in Matrix in both English and Welsh: http://www.eryri-npa.gov.uk/

Feel free to take a look at the source code on Eng/Welsh pages to see all the bits that switch between the contexts; title tags, metadata tags, images, navigation, feedback forms etc.

As you say, everything has to be available in both languages, not just the body content!



If you have any specific questions about the site set-up, let me know.



All the best,

Charlie.

[/quote]





Thanks for the link Charlie, having a real world example of what we are trying to do is invaluable. One question though - the site seemed quite slow when I visited - is this a problem with Squiz - what sort of hardware stack is it running on?



Thanks,



Jeff.


(Alderman) #11

I'm nearlythere but have a strange problem.


The following code switches between English and Welsh headers (crap code I know)



[xml]

<div class="page-header">

<MySource_AREA id_name="context_header_welsh" design_area="show_if">

<MySource_SET name="condition" value="keyword_regexp"/>

<MySource_SET name="condition_keyword" value="globals_context"/>

<MySource_SET name="condition_keyword_match" value="Welsh Context" />

<MySource_THEN>

<a href="http://www.caerdydd.ac.uk"><img src="mysource_files/cu_logo.gif" class="cu_logo"/></a>

<h1>Prifysgol Caerdydd</h1>

</MySource_THEN>

<MySource_ELSE>

<a href="http://www.cf.ac.uk"><img src="mysource_files/cu_logo.gif" class="cu_logo"/></a>

<h1>Cardiff University</h1>

</div>

</MySource_ELSE>

</MySource_AREA>

</div>



[/xml]



However, with the above code in place the following code only shows English no matter what the header displays. If I remove the code above the code below reacts to the context as expected - I can't see why this would be?



[xml]

<MySource_AREA id_name="menu" design_area="menu_normal">

<MySource_SET name="level" value="top"/>

<MySource_SET name="show_subs" value="on_current"/>

<MySource_SET name="settings.class.normal" value="" />

<MySource_SET name="settings.class.current" value=" class='current'" />

<MySource_SET name="settings.class.hierarchy" value=" class='hierarchy'" />

<ul class="nav nav-list uninav">

<MySource_ASSET>

<li ><a href="<MySource_PRINT var='asset_url'/>"><MySource_PRINT var="asset_attribute_name"/></a>

<MySource_SUB design_area="menu_normal">

<MySource_SET name="show_subs" value="on_current"/>

<MySource_SET name="settings.class.normal" value="" />

<MySource_SET name="settings.class.current" value=" class='current'" />

<MySource_SET name="settings.class.hierarchy" value=" class='hierarchy'" />

<ul class="nav nav-list uninav"">

<MySource_ASSET>

<li><a href="<MySource_PRINT var='asset_url'/>"><MySource_PRINT var="asset_attribute_name"/></a>

<MySource_SUB design_area="menu_normal">

<MySource_SET name="show_subs" value="on_current"/>

<MySource_SET name="settings.class.normal" value="" />

<MySource_SET name="settings.class.current" value=" class='current'" />

<MySource_SET name="settings.class.hierarchy" value=" class='hierarchy'" />

<ul class="nav nav-list uninav">

<MySource_ASSET>

<li><a href="<MySource_PRINT var='asset_url'/>"><MySource_PRINT var="asset_attribute_name"/></a>

</li>

</MySource_ASSET>

</ul class="nav nav-list uninav">

</MySource_SUB>

</li>

</MySource_ASSET>

</ul>

</MySource_SUB>

</li>

</MySource_ASSET>

</ul>

</MySource_AREA>



<div class="span6">

<MySource_AREA id_name="page_body" design_area="body" />

<!-- {CONTENT from WYSIWYG} -->

</div>

[/xml]



Again I emphasise the code is hacked about as proof of concept it's not purporting to be good coding :wink:


(Justin Avery) #12

I would dump the below code…

    

Prifysgol Caerdydd

Cardiff University



... and replace it with

    


This allows you to NEST in a standard page with the required header content and therefore allow you to utilise the Context feature to serve up the required cachable content for both the english and welsh sites.

It's good practice to ensure content elements are included into the design in this way as it means any edits are done via the page assets and can stick with any content workflows you might have. You also then limit any *mistakes* to nested areas rather than the parse file itself.

(Alderman) #13

Thanks for that - I can see the sense of it now.


Cheers,



Jeff.


(Alderman) #14

I'm obviously not getting something here,


I took out the code I had above and added the single line suggested.



[xml]

<MySource_AREA id_name="header_content" design_area="nest_content" />

[/xml]



I created a standard page under a folder called 'Nested Helpers' (which is where my EES Styles and Scripts asset is defined for the EES). In the English context I put the English header html and in the Welsh context I put the Welsh header html - I made this Live.



I added a customisation to my design called header_content (matching the area name) (also made Live).



I then clicked on the header_content customisation acquired locks and in the design area checked 'customise?' for nest_content (design area 'header_content').



I saved that and then followed the customisation and added a nested asset with the #id of the standard page with the welsh and english versions of the header.



All assets are live but I when viewing the page I don't see anything - neither the nested header nor the MySource area from the design parse file.



I hope this has not been too badly explained.



Any help gratefully received.


(Alderman) #15

Just to update you - I have this all working now as nested assets.


Thanks for all the help.



Jeff.


(Alderman) #16

Is there any mechanism in squiz that will allow us to alert a user to the fact that one language context has changed requiring the other language context to be updated? They just seem to be able to drift out of sync.