Elxis CMS Forum

Support => Language => Topic started by: mazzeltof on July 24, 2009, 16:25:54

Title: dynamic change of title ,discription, and meta tag
Post by: mazzeltof on July 24, 2009, 16:25:54
I have a site (momentarley in 2 language's)
is it possible to change title discription and meta tags allong with the changing of the language.

iff yes how

T.I.A.
Title: Re: dynamic change of title ,discription, and meta tag
Post by: datahell on July 24, 2009, 21:10:01
Yes you can easily do that.

How to guide
We will do this by overwriting configuration variables on runtime.
The overwrite must be done exactly after the elxis loader run and before the mainframe initialize.

Open Elxis' index.php (you will have to do the same procedure for index2.php later).

Go to line 30 (Elxis 2009.0 Pandora):
require_once($mosConfig_absolute_path.'/includes/Core/loader.php');
Add bellow something like this:

Code: (php) [Select]
if ($lang == 'italian') {
      $mosConfig_sitename = 'site name in italian';
      $mosConfig_MetaDesc = 'site description in italian';
      $mosConfig_MetaKeys = 'site, keywords, in, italian, comma, separated';
} else if ($lang == 'german') {
      $mosConfig_sitename = 'site name in german';
      $mosConfig_MetaDesc = 'site description in german';
      $mosConfig_MetaKeys = 'site, keywords, in, german, comma, separated';
} else {
     //do nothing (use default configuration for the site main language)
}
You can add as many languages you like. When finish save the file as UTF-8 without BOM (by default it is saved as ANSI as it contains only latin-1 characters).

If you have only 2 languages published the above code should be written like this:

Code: (php) [Select]
if ($lang == 'the secondary language here') {
      $mosConfig_sitename = 'site name in italian';
      $mosConfig_MetaDesc = 'site description in italian';
      $mosConfig_MetaKeys = 'site, keywords, in, italian, comma, separated';
}
Do the same for index2.php file.
Title: Re: dynamic change of title ,discription, and meta tag
Post by: mazzeltof on July 24, 2009, 21:32:00
sorry tried it but it does not work

go look at http://comsalon.nl and try changing the lang.

I know the logo and subtitle stay the same because they are in the template.

but look at title and meta discription and tags

Title: Re: dynamic change of title ,discription, and meta tag
Post by: datahell on July 24, 2009, 21:41:24
Read this:
http://wiki.elxis.org/wiki/Change_logo_depending_on_language (http://wiki.elxis.org/wiki/Change_logo_depending_on_language)
Title: Re: dynamic change of title ,discription, and meta tag
Post by: mazzeltof on July 24, 2009, 22:27:41
Quote
sorry tried it but it does not work

go look at http://comsalon.nl and try changing the lang.

I know the logo and subtitle stay the same because they are in the template.

but look at title and meta discription and tags
Title: Re: dynamic change of title ,discription, and meta tag
Post by: ks-net on July 24, 2009, 22:34:28
Read this:
http://wiki.elxis.org/wiki/Change_logo_depending_on_language (http://wiki.elxis.org/wiki/Change_logo_depending_on_language)

 the solution to it

also

read for multilingual site-title-meta without the need to hard-code
http://wiki.elxis.org/wiki/Frontpage_setup#Multilingual_Site_Title
 
Title: Re: dynamic change of title ,discription, and meta tag
Post by: datahell on July 24, 2009, 23:50:41
It would be a good idea kostas to add the ability to set the site title and meta data to the component front-page link. This way we would be able to set multilingual title and meta data easily. It is easy to be implemented and useful.
Title: Re: dynamic change of title ,discription, and meta tag
Post by: ks-net on July 25, 2009, 00:19:00
i agree ... another multilingual(and seo) characteristic ....a few db fields  for the next version

but.. in frontpage-link or in global-config(expand the current functionality)? which is best?

what about other pages that uses global-config values for meta-tags? wrappers...etc

Title: Re: dynamic change of title ,discription, and meta tag
Post by: datahell on July 25, 2009, 00:26:26
No other pages uses global meta data and title or at least, if any exist, they are too few. Elxis adds automatically meta data in each page except from the front-page. So I guess the trick with the front-page link's XML parameters will be enough.

Quote from: ks-net
...a few db tables  for the next version
db tables for what?
Title: Re: dynamic change of title ,discription, and meta tag
Post by: ks-net on July 25, 2009, 00:32:17
Quote
So I guess the trick with the front-page link's XML parameters will be enough
i suppose that no need for db table or fields...

something must be done for frontpage... also is more-seo to avoid duplicated meta and titles ... we get 2 in 1
Title: Re: dynamic change of title ,discription, and meta tag
Post by: Farhad Sakhaei on July 25, 2009, 09:38:56
Hi ,
I have a question , How we can add meta data and titles for all components ? for example for main of gallery , main downloads ... and etc ?
Title: Re: dynamic change of title ,discription, and meta tag
Post by: datahell on July 25, 2009, 09:49:19
The components control the page title and META data by themselves. To change this (not recommended) you have to edit each component.
The following elxis functions are used to set the page title and the meta data.

Page Title
$mainframe->setPageTitle('Page title here');

Meta Description
$mainframe->setMetaTag('description', 'meta description here');

Meta Keywords
$mainframe->setMetaTag('keywords', 'comma, separated, list, of, keywords');

The above functions should run before html is shown on screen.
Title: Re: dynamic change of title ,discription, and meta tag
Post by: Farhad Sakhaei on July 25, 2009, 09:51:26
is it better to include this feature in menu item of the components?
Title: Re: dynamic change of title ,discription, and meta tag
Post by: datahell on July 25, 2009, 10:00:35
No, the page title and the meta data changes depending on the selected task. So by placing such a feature in the XML parameters you will overwrite the proper meta data set automatically by the component. For example IOS Gallery will use the multilingual categories titles to generate meta keywords for the component front-page and will enrich these keywords by others that fits to an image gallery. This is done automatically and with multilingualism included. You can not achieve this with static XML parameters. The system as is, is perfect.
Title: Re: dynamic change of title ,discription, and meta tag
Post by: Farhad Sakhaei on July 25, 2009, 10:04:30
ok, thank you
Title: Re: dynamic change of title ,discription, and meta tag
Post by: mazzeltof on July 25, 2009, 12:38:25
is it not better to create db fields for this and ad extra fields into global metadata , wich you can read in, the same as now,  but then with a language selection.
the what you with artikels
Title: Re: dynamic change of title ,discription, and meta tag
Post by: datahell on July 25, 2009, 14:01:57
You don't have to create db tables or db fields. If you wish to store these info in db then you should use SoftDisk. SoftDisk in Elxis is a virtual storage area (virtual memory) that you can use for anything you wish. The system would be like the multilingual registration terms.

Sample SoftDisk setup for multilingual page titles and meta data

Section: METADATA

sdtype: STRING
sdname: METAKEYS_GREEK
sdvalue: comma, separated, meta, keywords, in, greek

sdtype: STRING
sdname: METAKEYS_ITALIAN
sdvalue: comma, separated, meta, keywords, in, italian

sdtype: TEXT
sdname: METADESC_GREEK
sdvalue: meta description in greek

sdtype: TEXT
sdname: METADESC_ITALIAN
sdvalue: meta description in italian

sdtype: STRING
sdname: SITENAME_GREEK
sdvalue: Site title in Greek

sdtype: STRING
sdname: SITENAME_ITALIAN
sdvalue: Site title in Italian

Links
SoftDisk for developers (https://forum.elxis.org/index.php?topic=1065.0)
SoftDisk and Static cache (http://wiki.elxis.org/wiki/Static_cache)
SoftDisk and multilingual terms and conditions (http://wiki.elxis.org/wiki/Multilingual_terms_and_conditions)
SoftDisk and users profile (http://wiki.elxis.org/wiki/User_Manager)
SoftDisk and content submission (https://forum.elxis.org/index.php?topic=3673.0)
Title: Re: dynamic change of title ,discription, and meta tag
Post by: mazzeltof on July 25, 2009, 14:48:53
so can i use it for this
Quote
I have a site (momentarley in 2 language's)
is it possible to change title discription and meta tags allong with the changing of the language.

iff yes how

T.I.A.

because the first hint did not work