Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 Yesterday 11:11:27

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

Re: How do I suppress a "missing form" error?

Bloke wrote #340412:

Any neat alternative deas?

<txp:etc_query url="path_to_svg" markup="xml" /> :-)

Offline

#14 Yesterday 11:23:14

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

Re: How do I suppress a "missing form" error?

etc wrote #340413:

<txp:etc_query url="path_to_svg" markup="xml" /> :-)

Haha. Shall we just remove every single <txp:...> tag in Textpattern 5 and replace it with etc_query? 🤣


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

Online

#15 Yesterday 11:24:30

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,453
Bitbucket GitHub

Re: How do I suppress a "missing form" error?

Offline

#16 Yesterday 12:24:27

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

Re: How do I suppress a "missing form" error?

Hehe, then my sites seem already running on txp 5.

Actually, <txp:image_info /> is probably not the best place for it, but <txp:evaluate /> might implement some raw xml import/process functionality, since it already uses a dom parser. Even in 4.9, maybe?

Offline

#17 Yesterday 12:34:06

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

Re: How do I suppress a "missing form" error?

etc wrote #340418:

Actually, <txp:image_info /> is probably not the best place for it, but <txp:evaluate /> might implement some raw xml import/process functionality, since it already uses a dom parser. Even in 4.9, maybe?

That’s a great idea. Love it. And not just applicable to images.

If it can be squeezed in now then it rounds off the SVG support nicely and paves the way for other amazing front-end processing tricks.


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

Online

#18 Yesterday 21:16:55

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,987
Website GitHub

Re: How do I suppress a "missing form" error?

Woah, this thread came a long way since I last checked in. Great feedback and ideas. Philippe, that makes absolute sense what you say. My case is a logo with different coloured parts that change with different backgrounds. I thought i was “being clever” by assigning the path groups inside the svg a css variable as the colour (with fallback) and then setting that variable via css depending on context. But I wonder if it’s backfiring by making the page source larger and not so easily cacheable. What is your educated opiniion on these options:

  1. The ‘clever’ way with the svg inserted into the source two (sometimes three) times with css variables doing the colour switching.
  2. Saving three preset colour variants of the logo and simply inserting the svgs as images. Presumably, the browser doesn’t need to reload what has already been loaded on another page?
  3. Variant 1 but using etc_cache to store the inserted svgs. Perhaps that retrofits caching to the insert-in-source variant?

One other idea (that I need to check). You can insert svg collections as symbolsets and then use the svg symbols in your pages. I can’t remember precisely, but I have an inkling that you can control some (all?) of the contents via css. The symbolset file is loaded once as an external resource, so is potentially cached by the browser.

etc wrote #340399:

Exactly. So what would be a natural syntax: form="my_form?", maybe?

Of the two, |* or ? I think I prefer the pipe-star.


TXP Builders – finely-crafted code, design and txp

Offline

#19 Today 01:03:21

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,451
Website

Re: How do I suppress a "missing form" error?

jakob wrote #340424:

[…]

  1. The ‘clever’ way with the svg inserted into the source two (sometimes three) times with css variables doing the colour switching.
  2. Saving three preset colour variants of the logo and simply inserting the svgs as images. Presumably, the browser doesn’t need to reload what has already been loaded on another page?
  3. Variant 1 but using etc_cache to store the inserted svgs. Perhaps that retrofits caching to the insert-in-source variant?

One other idea (that I need to check). You can insert svg collections as symbolsets and then use the svg symbols in your pages. I can’t remember precisely, but I have an inkling that you can control some (all?) of the contents via css. The symbolset file is loaded once as an external resource, so is potentially cached by the browser.

That last option (external SVG with <use /> suffers from the same problem as the <img src=""> approach in that you can’t go into the shadowdom – all you can style is the <svg/> itself. This article (dev.to/javar/external-svgs-that-you-can-style-2a37) suggest a possible but limited workaround with fill="currentColor" I haven’t tested.

Depending on the size of the SVG option 2 (use multiple versions loaded as img) is probably the most performant but a little less flexible. Inserting the whole SVG block (minified?) in the html is more flexible. Caching is a bit more of an issue, but gzip works very well on SVG blocks. And as you say, etc_cache might help.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#20 Today 09:32:37

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

Re: How do I suppress a "missing form" error?

I guess we mean the client-side cache here, so etc_cache wouldn’t help much. But you can borrow the idea of HTMX or its lightweight alternative HTMZ

  • store SVG as ‘external’ file
  • include this file via a hidden iframe
  • move the iframe content to the main DOM on load

Here is a prototype:

<style>
  svg path {fill: red;}
</style>

<script>
  function htmz(frame) {
    frame.replaceWith(...frame.contentDocument.children);
  }
</script>

<iframe hidden src="path/to/image.svg" onload="htmz(this)"></iframe>

Not fully tested, but should be straightforward and cacheable.

Offline

#21 Today 09:52:29

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

Re: How do I suppress a "missing form" error?

In 166 bytes of code?! What’s not to love about htmz?! That could be very handy for including, say, a cutdown Images panel for article image selection, among other uses.


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

Online

#22 Today 11:38:33

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

Re: How do I suppress a "missing form" error?

Each iframe cpu/memory overhead is like opening another window, so few is fine, but many can be problematic, especially in mobile browsers.

Offline

#23 Today 11:40:14

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

Re: How do I suppress a "missing form" error?

Absolutely. Everything in moderation.


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

Online

Board footer

Powered by FluxBB