Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2021-06-27 19:11:36
- Myusername
- Member
- Registered: 2019-12-12
- Posts: 162
two ways to do the same thing, which is better?
In terms of performance, which one is recommended?
<meta property="og:image" content="<txp:images name='header-image-<txp:section/>' limit="1"><txp:image_url/></txp:images>">
<meta property="twitter:image" content="<txp:images name='header-image-<txp:section/>' limit="1"><txp:image_url/></txp:images>">
or
<txp:variable name="head_image"><txp:images name='header-image-<txp:section/>' limit="1"><txp:image_url/></txp:images></txp:variable>
<meta property="og:image" content='<txp:variable name="head_image"/>'>
<meta property="twitter:image" content='<txp:variable name="head_image"/>'>
Offline
Re: two ways to do the same thing, which is better?
Not sure there’s much difference in raw performance. If memory serves, we cache the image requests (I’d have to check to be sure). But from a don’t-repeat-yourself and easier-to-maintain standpoint, option 2 is better as you only define the container once. Only one place to alter things if you want to change stuff in future.
FWIW, there’s also another variant, even shorter, and without the <txp:variable>
dance:
<txp:images name='header-image-<txp:section/>' limit="1">
<meta property="og:image" content="<txp:image_url />">
<meta property="twitter:image" content="<txp:image_url />">
</txp:images>
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
Offline
Re: two ways to do the same thing, which is better?
This is probably a hopelessly stupid idea…but could Debugging model tuned to show the time taken for each query, as well as the final total?
Offline
Re: two ways to do the same thing, which is better?
gaekwad wrote #330770:
could Debugging model tuned to show the time taken for each query, as well as the final total?
It kind of does, I think. By showing the start time of each query and its duration. Do you mean even more granular?
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: two ways to do the same thing, which is better?
Bloke wrote #330773:
It kind of does, I think. By showing the start time of each query and its duration.
You’re right. I could’ve sworn it was just a summary. Mea culpa.
Offline
Offline