Customer adding content. It works! The power of Sparkle with PHP

Every now and then, you get that customer saying; You design the website but I want to add the content (like a blog) my self.
Well, no way I will provide the Sparkle templates and no way that I will add the content myself each time. That is to much of a headache.

But there is good news. With the embedded code box, you can have the customer adding content him self by the use of PHP!

I have a Sparkle page to add the content, to change or delete the content and to browse the content. When adding or changing content, the customer logs in with a password first.

Make sure you do not type the full php script in the embedded code box. That would be a maintenance nightmare! Keep the php scripts separate in files. All you put in the embedded code box is something like:

<? Include “phpfilename.php”; ?>

For adding content (by the customer), create a Sparkle page with the functionality to submit a form, passing on a picture, title and text area. Then on submit, open an other Sparkle (thank you for adding) page, receiving the values. This page contains a php-include function of a php script to read the passed values (via $_REQUEST) and to store the values in a sql database.
To show the content, create a Sparkle page to show all the content (blog view), which holds the php file (include statement) to read the sql database and echo it as output. You can control the style with creating custom text style names In Sparkle and use these as classes in your php code (source code of the Sparkle page wil unveil the class names).

It is as easy as that and with this, Sparkle becomes better than Wordpress ever can be!

Awesome! :smiley:

Have a good weekend,

1 Like

@HPee, That sounds really great and I can see where you are coming from, but knowing that the content will move across a fixed layout/fixed breakpoints how will the clients blog input flow across the breakpoints, including optimising the images?

I haven’t done the blog thing yet (but soon), but I’m imagining it will be more of an after sales service where I take what they have and work a bit of targeting SEO before uploading and making sure it works well across all the breakpoints. That way everything is recoverable with an offline Sparkle file instead of a server-based SQL database.

I’m hoping that if their is some sort of database arrangement when Sparkle receives a blog that it is a flat-file system instead of a rational type SQL database - less complications, less potential for hacking, and less things that can go wrong!

I have no issues with the layout. I set the embedded code box to the desired width and the height only to 50px. The box itself only holds the php included statement for the php-file that shows all of the blog entries. The code box has a header and some text above and some info at the left, followed by a sticky footer. The layout is all done by Sparkle.

When php outputs the blog entries (for each entry a thumbnail and first 2 lines of a blog and a url link to the blog itself), it appears in the embedded code box, respecting the width set. The height will be as long as the list of blog entries requires (i can separate this in php into pages of 10 entries each).
So, I keep my Sparkle layout. The box is sitting perfectly between the header, the footer and what I put left of the box.

Again, this great stuff. The php is re-usable for any customer, the layout (specific per customer) is done in Sparkle. So, dynamic customer content, maintained by the customer him or herself in a layout specifically build (in Sparkle) for that customer.

With that, I have all that Wordpress offers plus the great features of Sparkle to build stunning website.


@HPee, Thanks for sharing a bit more detail on it… It sounds you have it working to what you’d expect of a blog. Down the track you might create a mock for us to all take a gander! :slight_smile:

1 Like

Having no experience with coding, I would like to see how this is working, maybe a tutorial? Thanks.

1 Like

Wow, that sounds great! Any chance to see a tutorial or get a dummy file how to set this up?
And as far as I know passwords are not possible in Sparkle or am I wrong there?
Best regards, Tom

Yes, it does because through the embedded element (code box), I use PHP and mySQL to store the password in a SQL database. With the embedded element, there are no limitations with what you can do with Sparkle. You can embed PHP, Javascript, etc to achieve what you want.