Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2008-02-23 22:09:02
- simsim
- Member
- Registered: 2006-05-06
- Posts: 70
The $atts variable
Hello,
I’ve been looking through the Textpattern code and I have a question about the $atts
variable which is passed as a parameter in many functions. What does this variable do? I can’t see where it’s get manipulated as almost every function I’ve seen , whether in the core code or plugins pass it as is!
Thanks.
Offline
Re: The $atts variable
$atts contains the attributes the user specified for that tag, when using it in a template or form.
For example, if you used a tag like this in your template or form:
<txp:example attribute="value" something="else" />
Then the corresponding example($atts)
function would receive the following array $atts:
$atts = array(
'attribute' => 'value',
'something' => 'else'
)
Most functions feed both the $atts array and an array containing default values for all attributes to the lAtts()
function, which returns the combination of the defaults and the user supplied attribute values (user values override the defaults of course). Using lAtts is very highly recommended when you’re creating a tag handler that accepts attributes, if only for that fact that it warns the user when he/she tries to use an attribute that your tag doesn’t support.
Offline
#3 2008-02-23 23:19:54
- simsim
- Member
- Registered: 2006-05-06
- Posts: 70
Re: The $atts variable
Thanks Ruud.
Well, I’m starting to get it, however, the nomenclature is a bit confusing to me. I’m assuming from Sable’s tutorial that lAtts
refers to local attributes. If so, then why the user-supplied attributes are passed to it? I was thinking that lAtts()
is a function to check if user-defined attribute(s) interfere with TXP’s native attributes and issues a warning when that happens.
Offline
Re: The $atts variable
Offline
Re: The $atts variable
Or simply look at the code for the lAtts function to see what it does. Plugin authors should be able to understand that code.
Offline
Pages: 1