Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2019-12-14 18:05:26

Myusername
Member
Registered: 2019-12-12
Posts: 162

Re: Two future feature suggestions

etc wrote #320530:

The layout will be very basic and unstyled, but your site is AMP-compatible as long as your articles body is.

I don’t mean that you are wrong, but in fact, it is not just the body of the article that needs to be compatible to have an AMP page.

Literally the whole page needs to be compatible: It is not allowed to use javascript, for example, whether it is inside <head> or at the end of <body>, there are also CSS commands that are not allowed, such as display: table.

You gave a good example of an AMP page, 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?

Here comes the alternate version of the page I mentioned earlier. So you can have your page showing all the power you want, and another version with AMP, which would be extremely more limited and simple. Of course, it will not be used by default, it will only be used when the user comes from Google search slides.

But the point here is that you can have an alternate AMP page from existing pages, displaying or hiding anything you want, which can only be accessed by using “/amp/” at the end of any publication’s URL.

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.

Last edited by Myusername (2019-12-14 18:06:53)

Offline

#14 2019-12-14 18:20:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Two future feature suggestions

If the large part of pat_if_amp is detecting if the URL contains /amp or 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. Maybe make up your own shortcode tag in a form. Up to you.

You could then serve a different, simpler stylesheet. Only key bits of content. Skip JavaScript. Whatever you want.

There’s so much you can do without plugins once you start weaving the power of the tags we introduced and enhanced in Textpattern 4.7.+.

Last edited by Bloke (2019-12-14 18:20:46)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#15 2019-12-14 19:27:08

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Two future feature suggestions

Bloke wrote #320534:

If the large part of pat_if_amp is detecting if the URL contains /amp or 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, and possibly Myusername, would appreciate a tags example here:).

Also, excluding the size of the images and some proprietry tags and specs, what I’m not sure about is the difference between AMP and the media css query. Maybe I am understanding it wrongly but isn’t AMP designed to serve lighter stylised content to mobile devices? Found it. Basically AMP uses Google as a proxy.

AMP pages are served to the user from the Google AMP cache.

Last edited by colak (2019-12-14 19:46:31)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#16 2019-12-14 23:23:14

Myusername
Member
Registered: 2019-12-12
Posts: 162

Re: Two future feature suggestions

Bloke wrote #320534:

If the large part of pat_if_amp is detecting if the URL contains /amp or 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

#17 2019-12-15 10:19:41

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

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

#18 2019-12-15 10:32:31

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

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

Board footer

Powered by FluxBB