KunGu Posted July 20, 2015 Share Posted July 20, 2015 Hi all! I'm totally new in CMS integration, and I chose PW to start my learning. After following the tuts available, I've launched myself in the "Delayed ouptut" approach to start. I'm now facing a problem, I think I misunderstood one of the basis concepts. I integrated the header and the footer of my website by writing HTML code to my main.inc, I think I'm ok for that. I just started to create my templates files for the homepage and here comes the questioning. I have some static content like a slider to put on the top of the body, so I have a large HTML code to write, and I don't want to be managed from PW. What is the best approach to integrate it ? Firstly I put my HTML code into my home.php, but I realized that I have to put it in a variable wich will be output in the main. But how can I integrate a large portion of code in one variable ? Using Heredoc ? Or do I have to create a separate file ? Thank you in advance for whom will give me some assistance I'm now a bit lost, and I don't want to use hacking tricks. Link to comment Share on other sites More sharing options...
diogo Posted July 20, 2015 Share Posted July 20, 2015 Hi KunGu, welcome to the forums! Eheh, you chose the most difficult way to start I don't thing that's a bad thing but I would suggest that you also do some test with the direct output, since it's the simplest to understand and most common way in CMS integration. Just to have a feeling of how it works. With the delay output, you got it right, Heredoc is one way to go. Other way is to concatenate the html pieces like this: // ultra simplified example $myVariable = "<p>"; $myVariable .= "content"; $myVariable .= "</p>"; You can also include the content of an external file into a variable in two ways: ob_start(); include('slider.inc'); $myVariable = ob_get_clean(); or: $myVariable = file_get_contents('slider.inc') Link to comment Share on other sites More sharing options...
KunGu Posted July 20, 2015 Author Share Posted July 20, 2015 Thanks a lot for your reply, I was not so far ! I thought that Heredoc was not the good way to go. I think it's heavy going to include some fields from PW with the heredoc syntax, and heavy going too to add contents like that : // ultra simplified example $myVariable = "<p>"; $myVariable .= "content"; $myVariable .= "</p>"; That's why I thought there was an easier way to go ! Thank you EDIT : Ok I just found out that I can use PHP variables into the Heredoc with {}. I thought I had to close Heredoc and reopen it. It's a lot easier now. Problem resolved !!Thanks again ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now