Jump to content


evaluating uncached snippets with API


  • You cannot reply to this topic
3 replies to this topic

#1 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 07 November 2007 - 10:45 AM

I have been trying to get the RSS Feed snippet to evaluate snippets to be returned in the feed. Page titles are only so helpful, I would like to be able to return the entire page including evaluated chunks and snippets, sanitised for xml.

I am having partial success... this link shows 2 pages, one returning a cached snippet (site stats). The other page, a cached and uncached snippet (on this day).

Using the API $etomite->evalSnippets I can evaluate cached snippet only. Uncached snippets only return the [!calling_tags!].

I have tried upping the snippet parses in the index.php file. It makes no difference.

Any ideas what else I could try?

I noticed that outputContent() checks for the non-cached snippets but it is well ingrained in the etomite output. Is there an easier way to evaluate non-cached snippets from a string?

This is the code I am using at the moment:
//evaluate chunks
$evalHTML=$etomite->mergeHTMLSnippetsContent($pageData['content']);

//replace uncached snippet tags
if(strpos($evalHTML, '[!')>-1) {
	  $out = str_replace('[!', '[[', $evalHTML);
	  $out = str_replace('!]', ']]', $evalHTML);
	  }
//evaluate snippets
$evalData=$etomite->evalSnippets($evalHTML);

//getPage content, make it xml safe and set the length to be returned
$safeContent=htmlentities(substr($evalData,0,$length));

Edited by Cris D., 07 November 2007 - 11:35 AM.


#2 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 07 November 2007 - 02:10 PM

How about using the good old $etomite->runSnippet($snippetName, $params=array()) API function call...???

EDIT:

After looking at your example page it reminds me that this is not that uncommon of a problem... However, when you run into this issue even a cached snippet can run as an un-cached snippet... I can't explain why it works this way, but I know it does... I have had the same problem when stacking snippet calls several levels deep... I run into this when I use my [!LayoutSelector!] in place of [*content*] in the page template on my site for selecting special chunk-based content templates for specific sections of my site...

#3 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 08 November 2007 - 10:11 AM

Quote

How about using the good old $etomite->runSnippet($snippetName, $params=array()) API function call...???
Right, but it is one thing to use runSnippet($snippetName, $params) when you know what snippet it is you are calling. It's quite another to identify the snippets in an array of document contents with pre_match_all, remove '?' and store the parameters, get the snippet names, count the results, then parse each one $etomite->runSnippet() (potentially several levels deep) with the correct parameters and return the result to use.

Sounds like a good API: runNonCachedSnippets($docContent)
//searches for (in a string or array) non-cached snippets and returns the parsed results.

I just thought Etomite might have had this hidden somewhere in the codebase already. There are pieces of it through various functions that I will try to sew together to get it to work.

#4 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 08 November 2007 - 02:12 PM

This minor problem happens so rarely that I can only think of maybe a half a dozen times when it has been mentioned... Yet ht e problem stems all the way back to when Alex originally incorporated caching into the code base and included snippets in the cache... At that point I don't think anyone had come close pushing the limits of what Etomite could do so it was a non-issue... Like I said above, I can usually tweak my snippet calls and the parser somehow manages to work around the problem... That would be my suggestion for now as I don't have any intentions of resolving the issue for the upcoming bugfix release due to time constraints... If all goes according to plan the new parser shouldn't be effected by cached versus non-cached snippet calls but we'll just have to wait and see...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users