You are not logged in.
Imagine…
Imagine a future tag which would allow a site/theme designer to register constants at a central location (a form or the location near the top of a page template) and use them later on elsewhere, for instance as the e-mail address for zem_contact_reborn’s to attribute or as the AdSense Publisher id for all three AdSense forms which are scattered throughout your template.
How would you benefit from this?
In detail (using the yet unofficial Textpattern 4.0.7’s tag attribute parsing):
Somewhere in the very beginning of a template you would define names & values, just like you do on your desktop calculator’s “memory” keys:
<txp:register name="site-owner" value="john.doe@example.com" />
<txp:register name="adsense-pub" value="pub-9999999" />
<txp:register name="client-is-always-right" value="yesss" />
Later:
<txp:zem_contact to='<txp:register name="site-owner" />' />
Conditionals would come handy at times
<txp:if_register name="client-is-always-right">
<!-- will change in two weeks, I'm sure -->
<txp:css n="fugly" />
</txp:if_register>
Elsewhere:
<script type="text/javascript"><!--
google_ad_client = '<txp:register name="adsense-pub" />';
google_ad_width = 120;
google_ad_height = 240;
//-->
</script>
Basically, you could control arbitrary aspects of your site’s implementation at one central place.
Thoughts? Pro? Con?
Try wet_quicklink | Me | @rwetzlmayr | +Robert Wetzlmayr | Repos
Offline
“register” doesn’t immediately convey what it does, particular when we already have such functions as register_tab, etc. Something like var would be better.
I’d much rather be defining these things in the admin itself somewhere, rather than in some page template where I’d forget where it was. Then having the tag allow you to override the value on an individual basis when it is needed (not often).
i.e., default client-is-always-right is yes but say on one page I want it to be no I could use <txp:var name="client-is-always-right" value="no" />.
My email address has changed recently. If you need to contact me, use the forum contact form.
Offline
So this will be something like “page template variables” or “custom fields for page templates”, right?
It would be a nice addition, particularly if those tags, being at the beginning of the template, can also be wrapped by conditionals, like txp:if_section (or any other), which probably is something you already though about.
Offline
If there will conditionals, it would be nice to have some check:
<txp:if_register name="client" isempty="1"> or <txp:if_register name="client" isempty="0"> or
<txp:if_register name="client" isset="0"> or <txp:if_register name="client" isset="1">
And, honestly saying, i’d like to see tag <txp:var /> insted of <txp:register />
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
Mary wrote:
I’d much rather be defining these things in the admin itself somewhere, rather than in some page template where I’d forget where it was.
One of the basics of my idea was to leave no traces in the database. Think templates, shortcuts to development ideas, variant testing. Maybe I’m wrong, but putting these into a central form (e.g. named settings) would suffice.
the_ghost wrote:
If there will conditionals, it would be nice to have some check…
Conditionals would test for value(s) and, in case no value is specified, for existence of a var. I.e.
<txp:if_register name="client" value="foobar">
or
<txp:if_register name="client">
Try wet_quicklink | Me | @rwetzlmayr | +Robert Wetzlmayr | Repos
Offline
Mary wrote:
“register” doesn’t immediately convey what it does, particular when we already have such functions as register_tab, etc. Something like
varwould be better.
“var” is a reserved keyword in PHP and can’t be used for function names. But since it can’t be a function name, the parser could check for txp_var instead (whenever an unknown tag is found), which is faster than the workaround for tpt_link.
Offline
Vote for core:)
neme.org | neme-imca.org | hblack.net | LABS
Offline