Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How do I suppress a "missing form" error?
The No form data found for: missing_form_name
error message obviously serves a debugging purpose, but can it be suppressed?
My situation: I have some svg images with separate path groups in them. To be able to style those groups individually using CSS, e.g. against different backgrounds, I need to insert the svg itself into the page source, rather than as an image.
My solution: Store them in forms and use output_form to spit out the source (or can I somehow output the svg source using txp:image?)
There will eventually (hopefully) be a title svg for each of the main sections but at present they don’t all exist. This means that:
<txp:output_form form='svg_section_<txp:section />' default=" " />
(with or without a default attribute) throws an error when there is no corresponding svg_section_{section-name}
form. I’ve tried wrapping this in txp:evaluate
but no luck; Textpattern’s error reporting is stronger.
Any ideas how I could get around this (except for making placeholder forms), or another way I could approach this?
TXP Builders – finely-crafted code, design and txp
Offline
Re: How do I suppress a "missing form" error?
Hmmm, error reporting is pretty persistent, as you’ve discovered.
Couple of alternative ideas, depending on how many images you’re talking about:
- Store the SVG in articles in a hidden section because they should be skipped if the references are missing, and easier to conditionally exclude if not.
- We could find some way to extend the 4.9.0 native SVG support by retrofitting (say) image_info with a
type
value that can return the raw image data.
Although not directly useful for types other than SVG, type="raw"
could be used to inspect the file header to manually check its mimetype in case the extension is incorrect.
Thoughts?
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
Re: How do I suppress a "missing form" error?
You can create one common placeholder form, say svg_default
(even empty), and use pipes:
<txp:output_form form='svg_section_<txp:section />|svg_default' default=" " />
The behaviour might be slightly different in 4.8 and 4.9, though.
We can enhance it a little, so something like
<txp:output_form form='svg_section_<txp:section />|*' default=" " />
would just suppress this warning. Syntax ideas welcome.
Offline
Re: How do I suppress a "missing form" error?
Both great ideas. Thanks!
Bloke wrote #340393:
We could find some way to extend the 4.9.0 native SVG support by retrofitting (say) image_info with a
type
value that can return the raw image data.
That sounds like a great idea. It’s a more logical place to store images and makes it less confusing for other users (or when you revisit your site years later).
Ideally, it would be better if one could actually load the svg as an external (and thus cacheable) image and control its contents via CSS, but I haven’t found a way. I know you can use CSS filters to alter the colour of an entire svg but don’t think you can address its actual contents, or pass through css variables to an external image, when they are defined in the svg. If someone knows of a better way, please tell.
etc wrote #340394:
You can create one common placeholder form, say
svg_default
(even empty), and use pipes:
<txp:output_form form='svg_section_<txp:section />|svg_default' />...
Bingo! That worked a treat in 4.9. I didn’t know that.
We can enhance it a little, so something like
<txp:output_form form='svg_section_<txp:section />|*' />...
would just suppress this warning.
That would save having an empty form. The default form variant is still useful, e.g. to fall back to a placeholder.
EDIT: How do the pipes work? Is it just one alternative fallback, or can you use more pipes? And then, is it the first match that counts, or all the forms output as if you were chaining them?
TXP Builders – finely-crafted code, design and txp
Offline
Offline
Re: How do I suppress a "missing form" error?
jakob wrote #340398:
How do the pipes work? Is it just one alternative fallback, or can you use more pipes? And then, is it the first match that counts, or all the forms output as if you were chaining them?
You can chain as many as you want, but only the first existing form will be returned. What bothers me a little with form lists is yield
attribute, that would then be passed to all forms, which is not always desirable.
Offline
Re: How do I suppress a "missing form" error?
jakob wrote #340398:
Regarding a potential type=raw
value for <txp:image_info />
That sounds like a great idea. It’s a more logical place to store images and makes it less confusing for other users (or when you revisit your site years later).
I like that idea too – seems like a neat, clear way to include SVG source forms. Would that filter apply to an uploaded SVG image too?
Ideally, it would be better if one could actually load the svg as an external (and thus cacheable) image and control its contents via CSS, but I haven’t found a way.
Well there are none for a simple reason: when you insert your SVG as an image with the <img /
html tag, you basically load a frame
containing the image resources (for SVG: you don’t load the XML code but the parsed, pre-rendered XML). In the same vein there is no way your main CSS file can style something inside and iframe
.
<txp:output_form form=‘svg_section_<txp:section />|svg_default’ />…
That is interesting Is that new to 4.9 that I missed ? Could be useful for something I am struggling to put together. Thanks for that.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: How do I suppress a "missing form" error?
phiw13 wrote #340405:
Regarding a potential
type=raw
value for<txp:image_info />
… which I thought would be simple but it’s weirdly refusing to play ball. It might be my server not having stuff open. But I’d expect this modification to Textpattern\Tag\Syntax\Image.php would work:
Step 1: Add ‘raw’ to the list of $validItems
.
Step 2: Modify the loop to handle raw directly (only 3 lines added here but I’m showing the rest of context)
if ($imageData = imageFetchInfo($id, $name)) {
foreach ($type as $item) {
if (in_array($item, $validItems)) {
if ($item === 'raw') {
$imageData['raw'] = txp_get_contents(imagesrcurl($imageData['id'], $imageData['ext']));
}
if ($item === 'category_title') {
$imageData['category_title'] = fetch_category_title($imageData['category'], 'image');
}
if (isset($imageData[$item])) {
$out[] = $escape ? txp_escape($escape, $imageData[$item]) : $imageData[$item];
}
} else {
trigger_error(gTxt('invalid_attribute_value', array('{name}' => $item)), E_USER_NOTICE);
}
}
}
But it doesn’t work in my tests. I even tried direct paths:
txp_get_contents(IMPATH.$imageData['id'].$imageData['ext'])
But nope. <txp:image_info type="raw" />
renders nothing.
Any ideas?
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
Re: How do I suppress a "missing form" error?
Guess you are seeing the SVG (that is an uploaded SVG, right?) with its default mime-type image/svg+xml
. For this idea to work, the first step would be to change it some text/xml
type.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: How do I suppress a "missing form" error?
It (txp_get_contents
) works for me (have you tried to dmp()
it?), but you get <?xml version="1.0" standalone="no"?>
and other declarations in the output, which can be problematic for direct inclusions. Not sure about this ‘raw’ idea.
Offline
Re: How do I suppress a "missing form" error?
phiw13 wrote #340409:
Guess you are seeing the SVG (that is an uploaded SVG, right?)
I’m not seeing anything. Like, it’s not even getting the contents and sticking it in the variable if I use dmp()
to view it.
But yes, when I get that far, because the data is “raw” I’m not sure how it’ll display. I expect jpgs will show as gibberish starting with 0xFF, 0xD8...
but whether SVG will render the actual image because the browser needs to be told not to output svg+XML I’m not sure yet.
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
Re: How do I suppress a "missing form" error?
etc wrote #340410:
It (
txp_get_contents
) works for me
Must be my server’s php.ini or security settings then. Thanks for the sanity check.
but you get
<?xml version="1.0" standalone="no"?>
and other declarations in the output
Drat. Yeah maybe this isn’t going to work. Any neat alternative deas?
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