AmadeuAntunes Posted September 9, 2015 Share Posted September 9, 2015 My question is: i'm new with this system and i have the new page created in backoffice of system, and now i would like to make the content of that page in main blog page. Can someone tell me how does it works? Link to comment Share on other sites More sharing options...
Andrei Posted September 9, 2015 Share Posted September 9, 2015 Hi, First, try to follow that tutorial : Simple Website Tutorials to see step by step the basic PW mechanic. Then, take your time to get around the rest of The Docs Meanwhile, I'll try a "short version" of that, with the content circulation from creation to the browser: 1> First you create a *CustomField* to store some content, who will be at the end shown into the browser. And giving to that field some unique name. 2> Then, your "Page" is more of a box where you store a set of specific CustomFields. That box is associated with one unique *Template* 3> The *Template* is simply a .php file stored into /site/templates/ 4> -Now the magic happen, basically as follow Assuming that you have a TextField, with the name "myContent", that you can fill in the backend on a Page (box) named "Test", and tied surprisingly to the test.php template ... 1. To output the Content (aka our field) on the Test Page, just open test.php template and in the chosen spot type: <?php echo $page->myContent; ?> // Classic form... <?= $page->myContent; ?> // or short form. 2. Basically again, if you need that content on another template/page than Test, you can pass from the global variable, and find the right "fields box" by the template name it use. So, on any other template, you can access the content of the "myContent" field like so: <?php echo $pages->find("template=test")->myContent; ?> // Classic form... <?= $pages->find("template=test")->myContent; ?> // or short form. PS: There are many other ways and forms to target and display the content, take some minutes with the Selectors - Don't know if I really understood your question ^^, but hope it helps a little. 1 Link to comment Share on other sites More sharing options...
horst Posted September 9, 2015 Share Posted September 9, 2015 2. Basically again, if you need that content on another template/page than Test, you can pass from the global variable, and find the right "fields box" by the template name it use. So, on any other template, you can access the content of the "myContent" field like so: <?php echo $pages->find("template=test")->myContent; ?> // Classic form... <?= $pages->find("template=test")->myContent; ?> // or short form. <?php echo $pages->get("template=test")->myContent; ?> // use get <?php echo $pages->find("template=test")->first()->myContent; ?> // or use first after find @Andrei: I think it is a typo, but an incorrect example may be confusing for beginners. $pages->find($selector) always returns an array, where you further need to select one item out, with e.g. ->first(), ->last() or ->eq(#). If you know that there is only one page that will match your selector, (or you only need to get the first match), you can use $pages->get($selector), which will return only a single item. 1 Link to comment Share on other sites More sharing options...
Andrei Posted September 9, 2015 Share Posted September 9, 2015 Ooops, indeed @horst, un inglorious typo 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