I thought $TYPE->parse_text() would parse out a tag but I guess not.
Is there a way to parse a tag such as “{exp:weblog:entries weblog="bayshore"}{body}{/exp:weblog:entries}”. Basicly I need to return the content of the tag since I cant output a tag with a tag and have it get parsed. I have to parse in the module. Or maybe a way to fetch a whole entry with just php like $class->get_entry($id) and it returns an array with all the entry data. Or am I just thinking about this the wrong way?
Should this return the body text or is there a method that will do this? * this is inside a module called as {exp:testmodule:test} in a template. The call to test() works but it returns “{exp:weblog:entries weblog="bayshore"}” not the real body copy.
function test(){
if ( ! class_exists('Typography'))
{
require PATH_CORE.'core.typography'.EXT;
}
$TYPE = new Typography;
return $TYPE->parse_type('{exp:weblog:entries weblog="bayshore"}{body}{/exp:weblog:entries}');
}
bhw1, Lisa is asking you to step back to describe the larger goal, from 30,000 feet, not with a lens on the specific question you’re asking. Reason being, the answer to your direct question might not be the help that you actually need, and we ask that you let our experience inform how we decide to provide development assistance.
One technical question that can be answered is that no, the Typography class does not handle the parsing of any tags, that is a job of the Template class. But heading down that road is in all likelihood the wrong direction.
bhw1, Lisa is asking you to step back to describe the larger goal, from 30,000 feet, not with a lens on the specific question you’re asking. Reason being, the answer to your direct question might not be the help that you actually need, and we ask that you let our experience inform how we decide to provide development assistance. One technical question that can be answered is that no, the Typography class does not handle the parsing of any tags, that is a job of the Template class. But heading down that road is in all likelihood the wrong direction.
Your welcome to call me Ryan, BHW1 is the company I work for.
My issues steams from needing to dynamically created tags. The current solutions for multi lingual sites does not fit our needs or is to easily broken by the user or my client. In the end I simply need to echo out the content of a custom field that set from data stored in $_SESSION. I have everything else working fine from the cp side. Its getting that content out I have been stuck on for a week. I first tried using tags, but you cant use a tag to complete a tag (think strict typing).
Example
{mycontent_{my_data_from_plugin}}
// Would parse as
{mycontent_en}
// that would parse in a second cycle assuming it ignored a malformed tag in the first parse cycle
My Content from the database.
After getting a better idea on the parse order and parse stages I understand there is only one pass for all {exp} tags so a {exp} for a plugin cant parse into a tag that can be parsed.
Ok I get that, but hey I can run php before hand, so I make the php create the tag. Well that worked but I could not access session data in the template, trying to set it get strange returns. It works in a plugin but you cant access a plugin without using a tag so I am back to my first idea. Found a session plugin but that had to use tags as well. Ok fine so I tried everything I could think of to access the plugin with php from the template. That also failed, I had to include it in the template for that to work. That just seemed bad semantically.
Then Lisa pointed out hooks for extensions. But all my testing and reviewing I found no hooks for the parse stages thinking if I can hook before the {exp} tag stage I could inject the tag, so again fail. So I moved into modules again plenty of hooks and classes but nothing for the parse stages, nothing for accessing content stored in the database. That I noticed anyway.
I know I am probably approaching this the wrong way. I just need a nudge or something in the right direction. I have tried posting examples but it seems the concept is getting lost or going over some heads. The CMS does seem very geared towards designers and I am approaching this from a OOP devs point of view. So when I cant just access a class or even a bridge API (MYMOD -> API -> TEMPLATE) I start to wonder why the CMS is structure with classes at all. It seems all the benefits are locked away due to scope/parse issues. With that said I am definitely not saying you are approaching this for reasons you pulled out of a hat. I just cant find any sort of basic design pattern (MVC, or more common for CMS’s Singleton). At this point I’m just trying to understand how the logic ties all the components into one.
Lastly I understand this is not a common need and some of the more basic approaches would work in the few cases. But without going into more details I need a solution I know my client (not a computer guy at all) cant screw up and users don’t get confused on. It should not require using the URI other than to setting it via _GET/_POST and does not require cookies.
Hope this helps understand my view on it, any insight is very welcome. I am worried if I confuse the CTO. Hiring a consultant is going to fail :(
I failed to add on a simple point to my long rant above.
I have
{exp:weblog:entries weblog="bayshore"}
{zone_en}
{zone_es}
{zone_ru}
{/exp:weblog:entries}
via php (be that in a plugin/module/ext) based on a session var need to parse out as
{exp:weblog:entries weblog="bayshore"}
{zone_es}
{/exp:weblog:entries}
The {zone_%%} is a custom field in that weblog so the session stores “en” or “ru” and its use is pretty clear.
That might be easier to understand than the rant above.
Hi, Ryan,
Thank you for the run-down. One of the developers in the community may be able to assist on the programming side; from another angle, however, have you considered looking at LG Multi Language? If not as a solution, as a starting point? I am not sure what methods you already tried but that one is a deeper take on the multi language requirement.
I wish I could see the code but that one requires either the URI to be set each time or to use subdomains. Both I want to avoid. Passing via the URI with the {segment} (or something like that) is plan C. I am just worried when it comes to complex pages that will hinder things to much. Best case for me is still having it set via sessions.
Nope, I completely understand, Ryan, including the need for it to be bullet-proof for your visitors. I think the issue you’re having stems from the false premise that you somehow need to create a tag or parse a tag from your module. Since the data comes from the Weblog module, your add-on would want to modify how that tag behaves. Let it do all the heavy lifting for you, and use an extension to provide it some road signs. As an example in this case, I’d probably begin with the weblog_entries_tagdata hook, which on each iteration over entries returned by the tag, you have opportunity to change what the tag sees needs to be parsed. You can pull out, add in, modify, or even manufacturer template variables as needed so that only what you want that visitor to see is shown. Make sense?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.