|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
jongos Smarty n00b
Joined: 26 Mar 2022 Posts: 2
|
Posted: Sat Mar 26, 2022 8:00 am Post subject: trying to Add dynamic canonical tags |
|
|
Hello
im trying add dynamic hardcode canonical tags within my head tags like this one ( cross domain canonical tags)
Code: | <link rel='canonical' href="https://www.domainname.com<?=$_SERVER['REQUEST_URI']?>" > |
Code: | https://stackoverflow.com/questions/21300474/create-a-canonical-url-with-php |
the code works fine in a regular PHP site but it's not working in smarty templating site (open journals system OJS)
the header.tpl is something like this
Code: | {**
* templates/frontend/components/headerHead.tpl
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* Common site header <head> tag and contents.
*}
<head>
<meta charset="{$defaultCharset|escape}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
{$pageTitleTranslated|strip_tags}
{* Add the journal name to the end of page titles *}
{if $requestedPage|escape|default:"index" != 'index' && $currentContext && $currentContext->getLocalizedName()}
| {$currentContext->getLocalizedName()}
{/if}
</title>
{load_header context="frontend"}
{load_stylesheet context="frontend"}
</head> |
can someone help me |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Sat Mar 26, 2022 8:12 pm Post subject: |
|
|
You will want the Smarty equivalent:
Code: | <link rel='canonical' href="https://www.domainname.com{$smarty.server.REQUEST_URI}">
https://www.smarty.net/docs/en/language.variables.smarty.tpl#language.variables.smarty.request
|
|
|
Back to top |
|
jongos Smarty n00b
Joined: 26 Mar 2022 Posts: 2
|
Posted: Sun Mar 27, 2022 11:35 am Post subject: |
|
|
thank you very much bsmither, you're a life saver |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Apr 06, 2022 11:17 am Post subject: |
|
|
Don't forget to escape the output value appropriately.
In both cases. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|