Getting PHP outputs in Pinegrow

As somebody who does about everything from the site (full-stack).
This means I do both the front-end as well as the back-end.

After building a design in Pinegrow and wanting to start building the back-end onto it.
This consisted of renaming index.html to index.php adding the Phalcon Framework (which I picked up a few weeks ago) and Let’s see if that works…

Nope it didn’t…
I got: https://i.imgur.com/0k0UzqY.png (in Pinegrow)
instead of: https://i.imgur.com/xkGeGm3.png (in the browser through my local development server)

So, this should mean, that there would be no CSS in my home.php… which indeed was the case:
(can’t add more than 2 links, but it was just a blank white page saying hooray it works)

Now how am I supposed to be able to update pages their templates in Pinegrow without:

  • Javascripts
  • Stylesheets
  • Certain missing PHP variables

I suppose I could just keep ripping out the back-end code and re-implementing it after I’m done updating the template, but that’s gonna be a huge pain in the buttocks.
I think that there should be an option that allowed PHP content to be returned by a PHP-enabled server so that I can see what I’m actually making of having to rip the back-end code out all the time just so I can get specific parts of the template to render properly in Pinegrow.

And don’t get me wrong, Pinegrow is amazing for building initial templates, but after that, it just seems to be lacking behind.

1 Like

I ran across this problem last year. Pretty much like you, design the front end and do most of my own back end work.

What I do is save the page/site in a folder on local linux dev server. Then preview the changes in browser. After getting use to this method like it better, cause seeing what changes look like in real browser.

Never used Phalcon so maybe I am of no help. Use a homebrew linux server with PHP5 and 7.

How do you mean?
Because then if I add back-end code, I can’t visually edit the front-end properly.

Not sure I follow what you mean. Check these docs and see if help you:

http://docsbeta.pinegrow.com/editing-php-html-templates/

Last year I got started off better by this thread:

I have seen that topic already, but it didn’t help me any further.
We have a lot of stuff in classes and functions over here (you could say it’s a homebrew framework).
For example, everything between the <head></head> tags is a different file we can edit, which then get’s slapped into the main page.
doing this already breaks the entire layout for Pinegrow.

Pinegrow is not meant to be a back-end development editor and will not work with anything like what you are doing.

You will need to import the completed html, what you would see in the browser and directly edit the html and css. Then export it out and manually break it back a part to fit into your framework.

From a standards based design process the html and backend code should always be separate and not merged together the way you are doing it. This was popular back in the mid 2000’s but is quite an outdated process today.

Instead of creating a bloated all in one framework, consider modularizing the basic functionality. Database integration, content processing and then build each site to the content, branding and purpose it is for. Be content focused and not backend focused, you will find that most of what you have built can be reduced down to very simple modules that can be reused and does everything that is needed. This way you can design specific to the site content and be done faster.

I developed all sorts of back end processes, classes, functions and interfaces… The vast majority I was able to get rid of entirely and simplify things down to just a few classes and functions that does EVERYTHING needed. I just tweak for each site. The end goal is to just have enough code to do what is needed, have 100% use and nothing that is not used. Bloat elimination, nothing in place that is not used, simplify to as few lines or line as possible. Small modules, small classes.

Do this and you will be happier and more productive being able to do more with less is a god send while still getting the end result desired.

1 Like

I don’t really understand how it would work out then?
Because if Pinegrow can’t speak back-end code, I should keep the front-end template (without the PHP code) away from the Pinegrow part.
So then it would come down to two things:

  • Use a boat load of javascript to communicate with a back-end
  • Keep adding all the back-end pieces over and over and over again (because according to what you say, I should not let the back-end code come near Pinegrow), which means that if I write a login page, I need to re-add all the code every single time, which (obviously) is really inefficient and time-consuming

I have broken down all my back-end stuff already in somewhat modularized basic functionality (page content loading is handles by 1 method, login detection is handled by another method), so I don’t see what else I could do?
I’ve been looking into stuff like EmberJS and AngularJS, and they still boil down to the same thing: the code that runs on the back-end (like loading op the requested page’s content), still will be into the main template, which is where Pinegrow fails to load it up.

Tho I suppose I could make another branch explicitly for front-end development in my Git repo (and make it protected) and put the back-end into another one and keep pushing, pulling and merging from the front-end to the back-end until I’m satisfied (after which I merge it into the master branch), but that seems like an awful lot of work to manage in the long-run…

1 Like

Pinegrow can display Javascript and PHP output but for server side you need to be running a local server of some sort. It is geared more to WordPress than anything else. There are videos and tutorials on how that all works with Pinegrow.

The front end pretty should never be mixed with backend code. For themeing to work you have to of course include a way to interact with the database. This is usually done with Ajax and actually does not take a lot of code to do this. For an example of one way this can work minimally look up Adam Khoury on Youtube and watch his more recent videos on Ajax implementations. The smaller the code is to do something the better, it does NOT need to be some huge framework or Javascript libraries.

If your code is the size of Wordpress, just use Wordpress and save yourself time.

What I have done is created entirely modularized code for Database integration. Adding, Retrieving, Deleting, Updating. Use PDO and prepared statements, this cuts down on the majority of pre and post processing you need to do via “code.” Also consider creating Views and Functions within your database itself whether that is Mysql, Postgress, Oracle or whatever. Let the database do the work for filtering and sorting content, that is what it is for. You do NOT need to do any of that in code at all, learn the features of your database and tell it to do the stuff you have been coding in PHP or whatever server side language you are using.

There is a great book on learning how to create Views and other more advanced things…
The Language of SQL by Larry Rockoff - Second Edition. This has saved me hundreds of lines of coding for things the database is designed to perform, just let it do it automatically and deliver the content in the form you need. You can do A LOT with little, really is a game changer when you learn to use the stack properly.

You just need the basic getting in and getting out of the database, convert it to JSON and let Javascript retrieve it then display it in your theme. For SEO there are a ton of things you can do including having a non-javascript fallback to get and display the content. Works same way as exporting JSON just have another option based on the request. Simple Switch or If Else statement will work.

Let the database do all the filtering, sorting and content mixing how you want then retrieve the completed result. Simple to do and setup. Don’t over complicate things, learn the moderate and advanced techniques for the technologies you are using and it will actually save you time and effort in the short and long haul.

Learn SQL specifically Views, Stored Procedures and Sub Queries… It will change your life or at least allow you to do more than what you thought was possible while keeping your server side code small.

1 Like

Did I mention that it also is more secure doing it this way than having everything in your code? Eliminates SQL injection and other forms of attacks by side effect.

SQL Injections are a rare occasion over here as I use an ORM.

I have looked into stuff like json APIs, but where I work, we generally don’t use them (company consisting of about 300-400 developers) as they are often too slow to update (like for example, you want your code to redirect users to the login if they aren’t logged in.
With Javascript, this can cause the user to see 1 page flashing, then they are redirected to the login page.
With PHP, this doesn’t happen (implying you have some session, which is why we never use Javascript for this stuff…