Path variables are never stored in memory, they are simply parsed and replaced along with other user-defined template globals at the very end of template parsing. If your plugin uses its own path variables, have a look at $FNS->extract_path() and $FNS->create_url(). Post back if you need additional help.
That’s actually what I was looking for, thanks, and I’m sorry for not phrasing it more clearly.
So now I have a working plugin, and that leads to to my second question. The plugin functions fine from a template, but not when I invoke it from a weblog field. No doubt that’s just the way it works, but I’m wondering how to do something that way.
When used as a field formatting plugin, the contents of the field are passed to the plugin as the first argument. So your plugin must accept the string. Here’s a common method:
function foo($str = '')
{
global $TMPL;
$str = ($str == '') ? $TMPL->tagdata : $str;
...
}
Essentially, if a string is passed, you want to use it, otherwise, you’ll use the tagadata.
Thanks, and I can see some interesting uses for that approach, but I can also see that I’m still not being clear about what I’m trying to do. Let me back up for a moment.
I’m using the Structure module to create a set of static pages. They all share a common template, and they get their content from five or six top-level weblogs, one for each major group of pages (parent and children and grandchildren).
A weblog feeding these static pages has a few fields, including an h1 title and a body-text field.
I also have a glossary (template and weblog) that glosses a set of technical terms used throughout the site. I want to gloss terms that appear the body-text field I’m referring to above. To gloss a term, I can use something like this:
<a class='gloss'path="resources/glossary">Some Term</a>
(I hope that comes through OK. I wish this forum had a preview function. I’ll repost if necessary.)
That’s awfully clumsy to type for every term I want to gloss, so I wrote a plugin that accepts this format and translates it to the above:
{exp:gloss}Some Term{/exp:gloss}
It works fine if I stick it in a template, but that doesn’t do me any good, since my body text is coming from a weblog field. But if I code it into a field, the parser ignores it, and I see the tags instead.
I can see one approach, namely to code my glossary references as (say)
<gloss>Some Term</gloss>
and then pass the whole field to a plugin that translates that pattern to the one I actually want.
An aside: there’s a ‘parse order’ page in the wiki that would be <strike>very</strike> even more useful if it were a little more complete. For example, it doesn’t show plugins at all.
(I hope that comes through OK. I wish this forum had a preview function. I’ll repost if necessary.)
I edited it for you, no worries. On these forums, you can use [code][/code] for code samples. And there is a preview, if you use the Post Reply as opposed to the Fast Reply form.
It works fine if I stick it in a template, but that doesn’t do me any good, since my body text is coming from a weblog field. But if I code it into a field, the parser ignores it, and I see the tags instead.
Ok I think I understand now - you have the plugin tag inside the entry itself. Content in entries is protected so that EE tags and PHP are not parsed. There’s a plugin “Allow EE Code” that will circumvent this for you, but I don’t personally recommend it unless you’re the only author of content on this site.
I can see one approach, namely to code my glossary references as (say)and then pass the whole field to a plugin that translates that pattern to the one I actually want.<gloss>Some Term</gloss>
Yep, that would work, or even some pseudo markup like [gloss]foo[/gloss]. Instead of a plugin, however, you’d probably want to code it as an extension of the Typography parser, so that they are always handled when text is ran through Typography. If you search the forums for a Footnotes extension, or a YouTube extension you’ll see some existing samples that do something quite similar.
An aside: there’s a ‘parse order’ page in the wiki that would be <strike>very</strike> even more useful if it were a little more complete. For example, it doesn’t show plugins at all.
Plugins are included under:
# Main Parsing - Process all {exp:…} tags in order encountered.
Hope that helps!
If I may add:
I also have a glossary (template and weblog) that glosses a set of technical terms used throughout the site. I want to gloss terms that appear the body-text field I’m referring to above. To gloss a term, I can use something like this:
You might consider the Acronym Module from Solspace.com, it seems like that might fit the bill unless there are other features you are after.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.