Mahmoud Posted January 14, 2018 Share Posted January 14, 2018 I want all the variables and the name of the files to be changed in the same code and not to create more than one code because it appears on all pages that it is empty. <meta name="keywords" content="{if $filename eq "index"}{$LANG.keywordsindex}{elseif $filename eq "shared-hosting"}{$LANG.keywordshosting}{/if}" /> <meta name="description" content="{if $filename eq "index"}{$LANG.descriptionindex}{elseif $filename eq "shared-hosting"}{$LANG.descriptionhosting}{/if}" /> <!-- Start Meta Page --> <meta name="keywords" content="{if $filename eq "index"}{$LANG.keywordsindex}{elseif $filename eq "ssl-certificates"}{$LANG.keywordsslcertificates}{/if}" /> <meta name="description" content="{if $filename eq "index"}{$LANG.descriptionindex}{elseif $filename eq "ssl-certificates"}{$LANG.descriptionsslcertificates}{/if}" /> <meta name="keywords" content="{if $filename eq "index"}{$LANG.keywordsindex}{elseif $filename eq "email"}{$LANG.keywordemail}{/if}" /> <meta name="description" content="{if $filename eq "index"}{$LANG.descriptionindex}{elseif $filename eq "email"}{$LANG.descriptionemail}{/if}" /> Link to comment Share on other sites More sharing options...
sentq Posted January 14, 2018 Share Posted January 14, 2018 use this ActionHook point to specify these variables values and pass it to your template, in your case the action hook file would look like: <?php add_hook("ClientAreaPage", 1, function($vars){ global $_LANG; $metakeywords = ""; $metadescription = ""; // Specify Homepage Meta Tags if ($vars['filename'] == "index"){ $metakeywords = $_LANG['keywordsindex']; $metadescription = $_LANG['descriptionindex']; } // apply the same for other pages... if ($vars['filename'] == "xyz"){ $metakeywords = $_LANG['xyzindex']; $metadescription = $_LANG['xyzindex']; } return array("metakeywords" => $metakeywords, "metadescription" => $metadescription); }); then in your template it should look like this: {if $metakeywords}<meta name="keywords" content="{$metakeywords}" />{/if} {if $metadescription}<meta name="description" content="{$metadescription}" />{/if} 1 Link to comment Share on other sites More sharing options...
Mahmoud Posted January 14, 2018 Author Share Posted January 14, 2018 2 minutes ago, sentq said: use this ActionHook point to specify these variables values and pass it to your template, in your case the action hook file would look like: <?php add_hook("ClientAreaPage", 1, function($vars){ global $LANG; $metakeywords = ""; $metadescription = ""; // Specify Homepage Meta Tags if ($vars['filename'] == "index"){ $metakeywords = $LANG['keywordsindex']; $metadescription = $LANG['descriptionindex']; } // apply the same for other pages... if ($vars['filename'] == "xyz"){ $metakeywords = $LANG['xyzindex']; $metadescription = $LANG['xyzindex']; } return array("metakeywords" => $metakeywords, "metadescription" => $metadescription); }); then in your template it should look like this: {if $metakeywords}<meta name="keywords" content="{$metakeywords}" />{/if} {if $metadescription}<meta name="description" content="{$metadescription}" />{/if} Do you allow me to tell you just one thing I Love Youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu Link to comment Share on other sites More sharing options...
sentq Posted January 14, 2018 Share Posted January 14, 2018 @Mahmoud thank you 1 Link to comment Share on other sites More sharing options...
Mahmoud Posted January 14, 2018 Author Share Posted January 14, 2018 Did not you work or should I add something? Is this really works for you? Does not appear to me <meta>! Link to comment Share on other sites More sharing options...
sentq Posted January 14, 2018 Share Posted January 14, 2018 3 minutes ago, Mahmoud said: Did not you work or should I add something? Is this really works for you? Does not appear to me <meta>! I've updated the action hook code, it should be $_LANG in PHP files, $LANG in Smarty files Link to comment Share on other sites More sharing options...
Mahmoud Posted January 14, 2018 Author Share Posted January 14, 2018 10 minutes ago, sentq said: I've updated the action hook code, it should be $_LANG in PHP files, $LANG in Smarty files Sorry, but you can explain more, I did not understand what you mean exactly Link to comment Share on other sites More sharing options...
sentq Posted January 14, 2018 Share Posted January 14, 2018 2 minutes ago, Mahmoud said: Sorry, but you can explain more, I did not understand what you mean exactly I've updated and tested my code above it should work with you now 1 Link to comment Share on other sites More sharing options...
Mahmoud Posted January 14, 2018 Author Share Posted January 14, 2018 I apologize to you, my brother it works well now and thank you again 1 Link to comment Share on other sites More sharing options...
Recommended Posts