Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read/write to XML file in data folder
#8
My understanding may be limited, but hooks are about adding content to the page where it otherwise wouldn't be (e.g. in the header or footer), whereas filters are about modifying existing content on the page (e.g. parsing the content field and replacing portions of the string). A clear example of this is when plugin developers allow users to put placeholders on their page content and still use a plugin, like RobA's External Commenting plugin or mvlcek's i18n Search.

I would look at External Comments for an easier to understand example. He returns the $content variable, searches it for the string that he wants to replace, replaces it with a function that calls the comments (in a return, not an echo) and concatenates it all together back into the $content variable to be returned at the end. That way, when the page content is called, the comments are shown wherever the user has declared the placeholder. This method either requires using explode(), str_replace() or preg_replace() to isolate the desired string (the last one requiring knowledge of regular expressions to get working, but ultimately being more flexible - though others might object that regex should be avoided).

(Also as a sidenote: my personal endorsement for creating XML files without having to worry about coding them is just to use DM Matrix. It exists for that very reason: easy plugin development Smile)
Reply


Messages In This Thread
Read/write to XML file in data folder - by arek1 - 2013-05-17, 22:33:07
RE: Read/write to XML file in data folder - by Angryboy - 2013-05-19, 17:26:44



Users browsing this thread: 2 Guest(s)