Jump to content

How to force the meta {title | description| keywords}


fruizz

Recommended Posts

Hello !

 

I try to add metatags (title, description, keywords) on my module but i didn't success

Here is my problem:

 

I created a module to access a static page similar to that site http://www.mywatchy....on.mywatchy.php

 

I try to force the meta in smarty like this :

//Meta tags

$mytitle="Mon super titre";

$mydescription="Ma super description";

$mykeywords="Mes supers mots clés";

 

$smarty->assign(array(

'meta_title' => mb_convert_encoding($mytitle, "UTF-8"),

'meta_description' => mb_convert_encoding($mydescription, "UTF-8"),

'meta_keywords' => mb_convert_encoding($mykeywords, "UTF-8")));

}

 

When I throw the smarty debug console on my page I get this

$meta_description Smarty_Variable Object (3)

->value = "Ma super description"

->nocache = false

->scope = "Smarty root"

$meta_keywords Smarty_Variable Object (3)

->value = "Mes supers mots clés"

->nocache = false

->scope = "Smarty root"

$meta_title Smarty_Variable Object (3)

->value = "Mon super titre"

->nocache = false

->scope = "Smarty root"

 

But the meta are not display and the title is still the website's name.

 

Do you have any idea ?

Link to comment
Share on other sites

  • 3 months later...

We are using .PHP files so you don't need to edit each page/"module" as I said before if you want to manually add metadata to fource it. Open themes/your-theme/header.tpl file and add the content you want in addition to that edit the admin/header.inc.php file

Edited by tjg (see edit history)
Link to comment
Share on other sites

In BO -> catalog -> add products

 

i cannot add content for Short description in rich text editor in mozilla firefox only.. but it works in google crome.

 

any one has any idea about this issue

Are you trying to copy & paste it? if so in firefox you need to allow for coy & paste
Link to comment
Share on other sites

Hi! Thank you very much for your reply.

 

I don't really want to change or add existing metadata. Everything is actually fine but I need to add meta title and description to my module.

I mean I made module with my custom page. Now only shop name is displayed in page title. Meta description does not exist at all.

I completely agree with that because title and desc are not assign anywhere.

 

$smarty->assign('meta_title' , 'My_Title');

 

does't work :(

 

I know one way to do that but is not quite elegant:

- create in root dir my-module.php (file with the same name as php file in my module) (file don't have to contain anything, just exist)

- go to BO->SEO->add new, choose my-module.php and fill the rest.

 

Is there any other way to make it work without going beyond the module directory?

Link to comment
Share on other sites

  • 2 months later...

I am using prestashop 1.4.8.2. I created a new php pahe called faqs.php in the root folder then copy pasted the code from the faqs.php fage from the modules/faq folder.

 

Then i went to admin panel and in prefrences/seo&url i selected add new and chose the pagge faqs.php and filled in the seo information like title meta tags and meta description. and also the friendly url

 

But when i go to the page using the friendly url it works it goes to the page but is unable to show the meta description and title and keywords that i have filled in.

 

I think the code in faqs.php somehow overrides the seo info that i filled in

 

 

Thnks for the reply. I am grateful. :)

Link to comment
Share on other sites

  • 5 years later...
<meta charset="utf-8" />
		<title>{if $p != 1 and $page_name == 'category'}({$p})- {l s='Страница'} {/if}{if $p != 1 and $page_name == 'new-products'}({$p})- {l s='Страница'} {/if}{if $p != 1 and $page_name == 'prices-drop'}({$p})- {l s='Страница'} {/if}{if $page_name == 'product'}{l s='Купить'} {$product->name|escape:'html':'UTF-8'} - Название магазина ✓ {$product->reference|escape:'html':'UTF-8'}{else}{$meta_title|escape:'html':'UTF-8'}{/if}</title>
		<meta name="description" content="{if $p != 1 and $page_name == 'category'}({$p})- {l s='Страница'} {/if}{if $page_name == 'product'}{l s='Купить'} {$product->name|escape:'html':'UTF-8'}{l s=' ➨ в магазине Название магазина ✓'} {else} {$meta_description|escape:'html':'UTF-8'}{/if}" />
		

 

Попробуйте это решение - мне помогло избавиться от дублей и +упростило жизнь СЕО-шникам.

Link to comment
Share on other sites

  • 7 months later...
On 7/27/2018 at 12:41 PM, Vadimuch said:

<meta charset="utf-8" />
		<title>{if $p != 1 and $page_name == 'category'}({$p})- {l s='Страница'} {/if}{if $p != 1 and $page_name == 'new-products'}({$p})- {l s='Страница'} {/if}{if $p != 1 and $page_name == 'prices-drop'}({$p})- {l s='Страница'} {/if}{if $page_name == 'product'}{l s='Купить'} {$product->name|escape:'html':'UTF-8'} - Название магазина ✓ {$product->reference|escape:'html':'UTF-8'}{else}{$meta_title|escape:'html':'UTF-8'}{/if}</title>
		<meta name="description" content="{if $p != 1 and $page_name == 'category'}({$p})- {l s='Страница'} {/if}{if $page_name == 'product'}{l s='Купить'} {$product->name|escape:'html':'UTF-8'}{l s=' ➨ в магазине Название магазина ✓'} {else} {$meta_description|escape:'html':'UTF-8'}{/if}" />
		

 

Попробуйте это решение - мне помогло избавиться от дублей и +упростило жизнь СЕО-шникам.

Hi Vadimuch can you update the lines for presta 1.7?

It doesnt work with 1.7.

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...