Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#16 2019-12-14 23:23:14
- Myusername
- Member
- Registered: 2019-12-12
- Posts: 165
Re: Two future feature suggestions
Bloke wrote #320534:
If the large part of pat_if_amp is detecting if the URL contains
/ampor not, you can probably do that with native tags now. Check the URL at the top of every page and set a<txp:variable>then test it at key points on your page via<txp:if_variable>to switch content.
I don’t know if it’s the best (and right) way to make it work. But I did it this way:
<txp:if_individual_article not>
<txp:output_form form="page_default" />
<txp:else/>
<txp:variable name="foo" value='<txp:site_url trim="/"/><txp:page_url/>' />
<txp:if_variable name="foo" value='<txp:permlink/>/amp/'>
<txp:output_form form="page_amp" />
<txp:else/>
<txp:if_variable name="foo" value='<txp:permlink/>/amp'>
<txp:txp_die status="301" url='amp/' />
</txp:if_variable>
<txp:output_form form="page_default" />
</txp:if_variable>
</txp:if_individual_article>
Last edited by Myusername (2019-12-15 08:09:32)
Offline
Re: Two future feature suggestions
Myusername wrote #320533:
however, you would have to limit my main page not to use some CSS commands. Also, what would you do if you wanted to use a library like Jquery?
I’ve heard Google recommends that AMP and not AMP versions match as close as possible and ranks higher ‘AMP only’ sites. So if you are developing a new site…
I’m working on the look of an AMP site on Textpattern using the “pat_if_amp” plugin, it will soon be ready and I’ll show you how it works, if you want.
Sure, please share.
Offline
Re: Two future feature suggestions
Myusername wrote #320543:
I don’t know if it’s the best (and right) way to make it work.
You could try also
<txp:evaluate query='contains(<txp:page_url escape="quote" />, "/amp")'>
AMP page
<txp:else />
regular page
</txp:evaluate>
Or register preg_match function in <txp:evaluate /> for fine-grained tests.
Offline