Show if design area


(gja) #1

Hi,

 

I am wanting to automatically set a different title tag when requesting the site asset.  

 

To achieve this I have added the following code to my parse file 

 

<MySource_AREA id_name="title" design_area="show_if"> <MySource_SET name="condition" value="asset_type"/>
<MySource_SET name="condition_types" value="site" />
    <MySource_THEN><title>%globals_site_metadata_Site_Name_EN% :%asset_type% : University of Waikato</title></MySource_THEN>
    <MySource_ELSE><title>%asset_name% - %globals_site_metadata_Site_Name_EN% :%asset_type% : University of Waikato</title></MySource_ELSE>
</MySource_AREA>

 

When requesting  the site:  I get <title>ResponsiveSite - Responsive Test Site :Site : University of Waikato</title>   this is showing that the asset type is a site, but the else condition is being executed.

 

Requesting a std page within the site the title is <title>link1 - Responsive Test Site :Standard Page : University of Waikato</title>  - returning the else condition as expected.

 

It seems rather odd that the asset type keyword is returning Site, while the show if condition asset type is site is never true.

 

Is this a bug?  I am running Squiz Matrix 5.1.5.

 

Thanks Georgina.


(Anthony Ponomarenko) #2

Hi Georgina,

 

I have submitted this as a bug as I could not find a solution to your issue, https://squizmap.squiz.net/matrix/6718.

 

Hopefully this will be resolved or someone will be able to provide a work around.


(gja) #3

Hi Anthony,

 

Thanks for your response, do I have access to view the bug?

 

Georgina.


(Edison Wang) #4

Those design areas are targeting the asset being printed, so it would be naturally the standard page in this case, not the parent site asset. It's expected behavior.

 

Keywords used in design parse file are replaced in the very end of code execution ( after the main asset being printed), at that moment, the site asset is the current asset to be replaced keywords against.  That's why it's printing the current type code as Site. This is a special case.

If you use that keyword in the page (instead of design), and preview the site, you will see it prints Standard Page now.

 

I can't really make the code change here to rectify the behavior of design areas so it would not use the asset being printed but use parent asset instead . It would be a significant behavior change that would break other client's implementation. For example, some implementation could use design area to print asset's name, they expect it to print the index page's name, and whatever page you are on, but if i make the change,  it will print the site's name.

 

 

Can you just work around it? like testing on the asset's url and see if it contains a '/', if it does, it's not the site asset. Or maybe mark the index page in metadata, and test on that metadata field.
Maybe we can also introduce new keyword to tell if the asset is a index page etc.

 

However, please understand there isn't an easy code fix to rectify behavior, it has to be very careful.


(Bart Banda) #5

Hi Georgina,

You should be able to just use a keyword modifier to print the asset_name at the start of the title if the current asset is not a site asset, no need for the show if design area.

 

Try this:

%globals_asset_type^replace_keywords:eq:Site::{asset_name}%%globals_asset_type^replace_keywords:eq:Site:: - %

This will conditionally print the asset name and the dash after it if the current asset type is not a site asset. 


(gja) #6

Hi Bart,

 

Thanks for that - it works like a dream.

 

Georgina.