can you use json in the head to assign current page url to smarty variable

soaringeagle
@soaringeagle
9 years ago
3,304 posts
heres the situation, i am working my way through developing a pro user tip to enable amp (accelerated mobile pages) functionality wich they say will give you higher rankings and referential treatment in mobile searches.

i have 99% of it figured out except for this
taken from the tech docs on amp

Linking pages with

In order to solve this problem, we add information about the AMP page to the non-AMP page and vice versa, in the form of
<link>
tags in the
<head>
.

Add the following to the non-AMP page:

<link rel="amphtml" href="https://www.example.com/url/to/amp/document.html">

And this to the AMP page

<link rel="canonical" href="https://www.example.com/url/to/full/document.html">

What if I only have one page?

If you only have one page, and that page is an AMP page, you must still add the canonical link to it, which will then simply point to itself:

<link rel="canonical" href="https://www.example.com/url/to/amp/document.html">

i edited the header.tpl to load a amp_meta.tpl when users on mobile, and not logged in
i will edit every page calling the header.tpl to call a amp_header.tpl when mobile and not logged in, this will include a message "you are viewing an accelerated mobile page, please join, or login for full functionality, and the most up to date content'

the regular meta.tpl will have link to amp url, wiich will simply be the http version of the url
while amp_meta.tpl will have the canonical link to the https version of the current url

heres the big problem, every module builds the urls based off base_url module url user id etc etc

that simply will not work for what i need
i need a json script (do they work in the head) or some way of capturing {this-url} minus the http/https assigning it to a smarty variable and in the link code just do http or https://{thisurl}

i hope that makes sense

once this problems figured out i should have a relatively easy way to make your whole site amp compliant

(though it may need testing and refining)
i am very close to having it figured out, just stuck on this 1 lil detail




--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities

updated by @soaringeagle: 04/28/16 02:04:22PM
michael
@michael
9 years ago
7,799 posts
The full url should be in the $_post variable. probably at $_post['_uri'] but check with {debug} to make sure.

If you need to alter that you can pass it to php for mainipulation via

Docs: "Defining your own smarty function"
https://www.jamroom.net/the-jamroom-network/documentation/development/1569/defining-your-own-smarty-function

You could pass anything in and have the manipulated version returned.
soaringeagle
@soaringeagle
9 years ago
3,304 posts
will that work on all modules including the index page


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
soaringeagle
@soaringeagle
9 years ago
3,304 posts
ok tell me if i got this right
i think its close
<link rel="canonical" href="https://www.dreadloockssite.com{if isset ($_post._uri)}{$_post._uri} {else}/{/if}">
<link rel="amphtml" href="https://www.dreadloockssite.com{if isset ($_post._uri)}{$_post._uri} {else}/{/if}">

that way the front page links to domain/ (it appears all post_uri has the leading /)
if the post_uri exists it appends it after .com

is this correct

(my tip might take 2 days, today was my birthday, tomoro is my first arial filming with my new phantom 3 drone (i just love having to buy my own xmass and bday presents haha)
so tomoros pretty busy
but as long as i got this code correct, i can finish making my site compliant i hope in 1/2 an hour and write up detailed instructions in an hour
it will only take that long cause i have to make a couple parts extra clear

i will still have to validate it make sure it works correctly


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities
michael
@michael
9 years ago
7,799 posts
HAPPY BIRTHDAY! :)

yeah that looks right
soaringeagle
@soaringeagle
9 years ago
3,304 posts
whew awesome
it took a lil poking around and guesswork
your always such a help


--
soaringeagle
head dreadhead at dreadlocks site
glider pilot student and member/volunteer coordinator with freedoms wings international soaring for people with disabilities

Tags