Adding extra meta data into Pulse

Some of you will have seen my post on Twitter recently about wanting to add extra meta data to the blog editor in Pulse.

I'm in the process of developing a script for a project that relies on a certain amount of information being scraped from Pulse blog posts. Most of the data I need is covered by Pulse already; post title, post date, post content etc but I also need at least one extra line of user supplied data. I thought about tacking this on to the end of the blog content or asking the client to hide it in an HTML comment but after exploring these options they all seemed like pretty basic hacks and didn't make the workflow look at all nice.

What I've done is to extend Pulse to allow for an extra two meta data fields. These are displayed along with the blog post title and date. The data for the fields is stored alongside the original blog post file (1.txt, 2.txt, etc) and is stored in an html file so as not to get listed by Pulse as a blog file itself. What you'll end up with is a blog directory that contains the original blog file (1.txt for example) and the meta data for that post (1-meta.html).

These alterations to Pulse will work of my project and may be useful to others but it comes with a few limitations that you should be aware of;

  • This is experimental work. Use it with caution, or ideally, not at all!
  • The core file admin/inc/open.php had to be manually edited. If you update Pulse in the future this file will get written over and you'll lose this extra functionality.
  • It only works with blog posts. If you want it work with pages as well then you'll need to edit the files.
  • The extra meta data fields are hard coded into the extrameta.php file. The file needs to know how to both read and write the data back to the file and this is where that happens.
  • The script only supports text data. If you can represent your data as text then it should work for you. Ideally this should be extended so you can define anything here; image uploads, checkboxes, select lists, sliders etc.
  • To make use of this new data your theme (or super block) will need to go and find the file and extract the data itself. I'll leave this as a exercise for the reader. :slight_smile:

Here are the files for this. They both live in the admin/inc/ directory. Be sure to have a backup of the original open.php file before you copy these in.

So here's my feature request;
Can a future version of Pulse please have the ability to read in extra meta data config files like this?

1 Like

Well this is embarrassing. :blush: I just found an error in my edits to the open.php file so if you’ve already downloaded that zip file please download it again.

1 Like

I managed to add extra meta data for galleries too. By changing the captions.php file, gallery.txt can hold extra meta data (in the same file). Unfortunately the data is removed after deleting any of the images, since gallery.txt is completely rebuild by Pulse admin.
To work around this I’ve modified /admin/inc/delete.php by only changing line 36 of the 4.5.2 source file.

I changed:
if($image[0] == $del[2]){ } else { $new_data .= $image[0] ."|". $image[1]."|". $image[2] ."\n"; }
to:
if($image[0] == $del[2]){ } else { $new_data .= implode( "|", $image ) . "\n"; }

It would be great if this simple tweak would end up in the next version, so I can further develop this functionality and share it.

1 Like

Good work @sprksld. This looks really promising.

The more I think about how Pulse stores data in flat files the more I tend to veer towards wanting it to use something a little more robust like XML or JSON. At the moment the data structure works well for the current CMS features but all of this data is held in hard coded locations within the files. This was one of the reasons I used my own file for the extra meta data as I could be sure that it wouldn’t step on Pulse or the CMS wouldn’t step on my files.

A single data file per page/post/blog makes more sense and is a lot quicker but the data does need to be properly ring fenced so it can be easily added to and accessed without fear of clashes.

1 Like

Great work @sprksld and thanks @TimPlumb

Pulse 5 is moving towards storing some data in JSON

This allows a lot more flexibility including better security, blog tags, storing theme+plugin information and any other ideas (like these) we have later on once this in place :slight_smile: This should open a lot of doors into the future.

It means adding another directory or two to the Pulse files but still the footprint is small and the functionality benefit outweighs anything else.

Oh and it’s fast too so no performance hit :slight_smile:

1 Like

Pulse5 has plenty of extra Meta data now :slight_smile:
http://help.pulsecms.com/article/10-version-history