Dynamic content with PHP/PGSQL possible?

Good evening (o;

Just stumbled upon Sparkle when I was looking for web development tools…
Downloaded the free version and like the fact that I can do a design for several devices at once…

With a little search I could tell Apache to also parse PHP code in the embed box…

But is there really no way in embedding PHP into any text box at all?

That would make websites with dynamic content fed from a PGSQL database very difficult in going through the generated html files and insert the code there manually…

thanks in advance
richard

Hi @davorin, welcome!

First off Sparkle is not focused on coding or development needs, there are many tools for that and we focus on the visual aspects. That said you are of course welcome to use Sparkle in your web dev toolchain if that helps you, with as little or as much code as you want.

Yes it is possible to put PHP code in an embed box in Sparkle. Just be sure to turn off the “activate after consent” checkbox, as that encodes any content to prevent it from loading until the cookie banner has been accepted.

Hello all,

Want to push this topic again as my “challenge” is similar…
I’m currently trying different WEB-designer tools before purchasing and so Sparkle as well. What I’m looking for is aa easy WYSIWYG web-designer, with php support. I learn that it is somehow possible with Sparkle but cannot get a working version. What I tried:
1 page, 1 button to activate a layout block, on embedded code block. I already tried with 2 external files, one html simple “hello World” and one php with DB-request and output. All is running on MAC and XAMPP.
What I could not find is the correct code for referencing the files to get them loaded to the embedded block. For the php file I found something in this forum: <? include "filename.php"; ?> → not working. I also tried <? require 'filename.php';?> which didn’t work as well. All files are located in the same dir. Can someone help me here?

Thanks for your support!

I have seen that Sparkle offers a Developer tool for adding scripts, you might try that one out.
Thinking getting this one too but there is no price on the website.

Hi,

I don’t think that this is what I’m looking for. I want to klick on a button-> a layout block appears → external content (created by a php-script) is loaded to an external block. For this, I must be able to include the external file (see attachment). Best case is to load content to a referenced block in case of defined events (button click).
Developer tools are more or less for static load of of content.

Best regards,
Steffen

Missed to add the attachment …

OK, got it:

But is there any way to not use iFrames but address a sparkle-element directly? For example Buttons can run javascript code… How can I reference a (for example) text-field w/o having an ID or something similar? I tried to access a textfield (TE6) as well as a smart field (test1) by adding javascript code to a button: document.getElementById(“test1”).value = “myValue”; → does not work

Sorry, if the questions / description is stupid… just learning :wink:

Turns out that’s incorrect syntax. PHP starts with <?php. In general though Sparkle is not a coding environment and while we don’t discourage anybody from trying, there certainly are many many solutions for coders so we don’t focus on it too much.

Hi Duncan,

That’s not correct: short php tag is <? and as you can see in the screenshot, it works. The question was, how to address certain elements by id via java script. And as Sparkle announces to offer js support (see attached), my question is valid. Sure you have to add some lines of code but as long as this can be done within the Sparkle app, it is valid to focus on this. Sparkle (by looking at the price) is worth nothing w/o this feature (I assume this for 90% of web designers) as modern pages with DB-access and dynamic content needs more than html. The output files are massively cryptic so that manipulating them seems not to be wanted.
So coming back to my question: Is there any documentation or information on how to use the JS-support in Sparkle? Examples?

you could go into site settings > miscellaneous > allow html element id customization, which will open a field so you can define an ID to any select element

but as Sparkle isn’t focus on developers and mainly on drag-and-drop, you won’t find much documentation. The ability and choice to use the developer tools is on your own (hence why it is sold apart from Sparkle itself) as this is not the focus, at the moment, of Sparkle

1 Like

I’m a a Web Designer (probably the 10%) and I’m not phased that Sparkle isn’t built around the Developer’s code world. Sparkle is a different take on web design and your Sparkle is the CMS so things are a bit more manual then auto-script and database driven!

But I have to say that over the last 3+ years I have had no hacking of any of my clients websites, so very happy with the price, saving me the headaches of the past! :slight_smile:

There’s this misconception among some web coders that Sparkle is actively working against them, hiding or obfuscating content in order to make it harder to edit the pages. This is 100% not the case.

First, Sparkle is not aimed at web coders, for whom there are many many tools that can help them.

But the code is not obfuscated or made hard to edit, rather it’s optimized and web ready in order to hit specific performance goals in lighthouse, pagespeed insights and other tools. Additionally the sometimes convoluted markup is the result of what is now years of testing of different combinations of elements and getting them to render consistently across different browsers.

Artisanal code crafting often foregoes the extra pixel or not-quite-as-intended layout, because there’s no visual reference. Sparkle’s code is not artisanal, it’s engineered to produce the intended result in a variety of conditions and with a variety of browsers. To say it’s cryptic is just to not understand what it’s trying to do. There’s purpose and days and sometimes even weeks of work behind every aspect of the code.

Sparkle’s pricing reflects its ability to produce extremely well coded websites, in fact better than 90% of what web coders out there are able to do, while being extremely intuitive to use. If this isn’t of value to you, which is an absolutely legitimate stance, it simply means you are in the top 10% of web coders and can do better by hand coding. Kudos to you, but this doesn’t diminish Sparkle.

Yes creating dynamic content is certainly a valid use case for a website, but Sparkle focuses on static sites right now. It’s not necessarily straightforward to do with Sparkle, but it means you’re in a very narrow space of someone who absolutely needs Sparkle, and also absolutely wants to put a finishing touch that can only be done via some code. The pricing of the developer tools reflects this niche.

Using the “run javascript function” feature requires some understanding of what Sparkle does, and that feature is certainly not much documented. We run a fine line between documenting how that works and explaning coding practices. We have erred on the side of documenting this insufficiently, but as @primo has illustrated, you might need to understand the Sparkle basics a bit more, to see where and how things fit together.

In your example it’s unclear whether you have added the “test1” id to the text block, and looking at the DOM what you probably wanted is:

document.querySelector('#test1 p').innerText = "abcdef";
1 Like

Hi all,

Don’t missunderstand me, I do not want to discredit the quality of the app itself. For static content it is a powerful tool. But the world has moved on and static content is 90s style. I am definitely NOT a top web coder and search for a tool, which allows to skip introducing myself to html and css creation. My focus is dynamic content. What I want to do: I have a Java server which collects periodically data from different Arduinos (connected to different sensors and actors like temperature, humidity, relays…). These controllers are managing my house. To have a centralized control panel, I decided to have a website. This cannot be static as it has to read and write data from and to databases and TCP/IP-sockets (working by php scripts…currently looking ugly;)) . For this, I’m searching for a WYSIWYG-designer which either allows to integrate php/js or creates simple results. That’s what Sparkle cannot support (even JS or external code seems to be indicated, but not working) or where there is a huge lack of documentation. Sparkle is drag and drop, effects and colors but w/o modern dynamic content. So perfect for static presentation but not fulfilling needed requirements for more.

Thanks a lot for your comments, you are doing great… but think we can stop here…

Best regards,
Steffen