Page 1 of 1
Replacing Global Metadata with extra page attributes
Posted: Thu Jun 10, 2010 6:35 pm
by pmckeown
Hi,
I am using extra page attribute 1 for the meta description and extra page attribute 2 for the meta keywords
Is there an [if} statement I can use to display the Global Meta Data only if the extra page attributes 1&2 are left empty.
At the moment the meta tags are appreaing twice.
Regards
Pat
Re: Replacing Global Metadata with extra page attributes
Posted: Thu Jun 10, 2010 6:46 pm
by Rolf
Re: Replacing Global Metadata with extra page attributes
Posted: Fri Jun 11, 2010 1:12 pm
by kermit
in site admin -> global settings -> general settings -> global metadata, try:
Code: Select all
<meta name="keywords" content="{capture assign=e2}{page_attr key="extra2"}{/capture}{if $e2 neq ''}{page_attr key="extra2"}{else}default,keywords,here{/if}" />
<meta name="description" content="{capture assign=e1}{page_attr key="extra1"}{/capture}{if $e1 neq ''}{page_attr key="extra1"}{else}default description{/if}" />
_____
what i did was a little different. i removed those two lines (meta keywords, meta description) from global metadata and inserted them in page default metadata instead, modified as follows:
Code: Select all
<meta name="keywords" content="{global_content name='meta-keywords'}" />
<meta name="description" content="{global_content name='meta-description'}" />
those two global content blocks contain site-wide defaults. then in page edit mode, i just add page-specific data before the gcb, like this:
Code: Select all
<meta name="keywords" content="this, page, keywords, here, {global_content name='meta-keywords'}" />
<meta name="description" content="this page specific description. {global_content name='meta-description'}" />
i could also just change the gcb called and have several already made-up for various pages or areas of a site.
Re: Replacing Global Metadata with extra page attributes
Posted: Sun Jun 13, 2010 4:19 am
by pmckeown
Hi
Thanks for the assistance - very helpful
Regards Pat
Re: Replacing Global Metadata with extra page attributes
Posted: Mon Jun 14, 2010 8:05 am
by Rolf
Hi pmckeown,
If your question is answered here, would you please be so kind and put [solved] in the title of the
first post? You can use the modify button for this.
Have fun, RolfÂ

Re: Replacing Global Metadata with extra page attributes
Posted: Sun Jul 04, 2010 9:06 pm
by kermit
i was looking at doing the same thing, using per-page extra attribute for meta tags such as 'description', but the field length (255) is too short for some implementations.
Re: Replacing Global Metadata with extra page attributes
Posted: Thu Sep 02, 2010 2:59 pm
by beherenow_uk
Hi Kermit,
Im not sure if this is seen as 'editing a core file' or not, but we also had the same issue for wanting to extend the extra attribute field length...
So I edited the file /lib/classes/class.content.inc.php on line 2085, 2091, 2097 and changed the maxlength="255" bit to maxlength="600".
Our SEO guy is a very happy man now.
kind regards,
Karl.
Ps - if this is seen by the admins as hacking a core file, please could you let me know. Im not sure what constitutes a 'core file' as I'm new here

Re: Replacing Global Metadata with extra page attributes
Posted: Thu Sep 02, 2010 3:22 pm
by Rolf
beherenow_uk wrote:
Ps - if this is seen by the admins as hacking a core file, please could you let me know. Im not sure what constitutes a 'core file' as I'm new here
Yep, this is hacking the core files... Not serious, but... there are alternatives
And these changed files are overwritten when doing a upgrade!
A better solution in my reply posted above:
http://forum.cmsmadesimple.org/index.ph ... #msg212993
It uses the {content} tag.
Same flexibility, but you don't need to change core files anymore.
Hope this helps
RolfÂ

Re: Replacing Global Metadata with extra page attributes
Posted: Thu Sep 02, 2010 4:24 pm
by beherenow_uk
Ahh... I see,
Thanks Rolf, that is a much better solution.
best,
Karl.