ryan

Small Project Walkthrough (Planets)

Recommended Posts

Lovely little walkthru - thank you!

Because I wanted the planet pages to look like the basic pages, I copied some code and now my planet.php looks like:

<?php 
include("./head.inc"); 
?>
  <h2>Type: <?= $page->planet_type ?>, Age: <?= $page->planet_age ?> years</h2>
  <p><?= $page->planet_summary ?></p>
<?php 
echo $page->body;
include("./foot.inc"); 
?>
 
I then added the body field to my planet template. My intention is to write additional content to supplement the planet_summary. When I edit the Earth or Jupiter pages by pasting
 
A <?= $page->planet_type ?> is a planet that is composed primarily of silicate rocks or metals.
 
into the Body editor, after switching it to HTML Source editing mode, the result is not what I expected. Can't I mix PHP in with pure content? Or do I have to use some special templating syntax?
 

Share this post


Link to post
Share on other sites

Welcome to the forum Gas Creature (feels a bit strange to say this :))

No, you can't do that. You can only put plain text on the fields, and also html in some (but try not to), but never php. Usually you wouldn't need to have this kind of dynamic content in such a place, because you will always know what is the type of planet when you fill the body (you are inside that planet's page, so you must know). If that need arises... and this would be only to prevent repetition, there are ways to do it in the template file with some more advanced functions http://php.net/manual/en/function.preg-replace.php

  • Like 1

Share this post


Link to post
Share on other sites

Thanks diogo. I just wanted to know what I can or cannot do. Indeed, I can code up the template file in any way that I like. BTW, that link you included to php.net is dead, apparently.

Share this post


Link to post
Share on other sites

The problem with the link is that I included the dot in the end. I will correct it.

Share this post


Link to post
Share on other sites

Just finished this tutorial, and one of the natural follow up questions/next steps for me is "how do I now apply this stuff to my site which is all one level above the folder in which all of Processwire is in? Instead of applying it the the sample website" (Right now I have a folder in my root folder named "processwire", which is on the same level as the files and folders for the main website) Would I just cut and paste out everything in the processwire folder out to my root directory?

Thanks for the nice simple beginner tutorial, btw. I experienced this fleeting sense of childhood joy learning something simple yet very cool. 

This is also my first time posting and my first time starting to really use a CMS ever (or at least feel like I'm effectively using one). I've literally tried to start with dozens of others, but shied away from them because  they seemed too complicated. It took me over a month to get a wordpress page going, but now that's scraped. And after months (I'm volunteering) I feel like I'm finally going to get my client set up with a good CMS. 

Share this post


Link to post
Share on other sites

Just finished this tutorial, and one of the natural follow up questions/next steps for me is "how do I now apply this stuff to my site which is all one level above the folder in which all of Symphony CMS is in? Instead of applying it the the sample website" (Right now I have a folder in my root folder named "SymphonyCMS", which is on the same level as the files and folders for the main website) Would I just cut and paste out everything in the Symphony folder out to my root directory?

Thanks for the nice simple beginner tutorial, btw. I experienced this fleeting sense of childhood joy learning something simple yet very cool. 

This is also my first time posting and my first time starting to really use a CMS ever (or at least feel like I'm effectively using one). I've literally tried to start with dozens of others, but shied away from them because  they seemed too complicated. It took me over a month to get a wordpress page going, but now that's scraped. And after months (I'm volunteering) I feel like I'm finally going to get my client set up with a good CMS. 

Symphony CMS?

Are you confusing ProcessWire with another CMS, or are you trying to get ProcessWire to work alongside SymphonyCMS?

Share this post


Link to post
Share on other sites

Oh, haha, no it's because I tried using Symphony before this and forgot to rename the folder haha. I just realized I mistyped this too. Was working very late last night. 

Share this post


Link to post
Share on other sites

Welcome jqnerd!

Depends on what you want. If you want to heve the processwire site appearing in the domain: www.yourdomain.com/processwire, then you should put all the files that come in the zip file, in the "processwire" directory. If you want the processwire site to be in the root domain www.yourdomain.com, you should put those files in the root directory.

Share this post


Link to post
Share on other sites

Thanks! :)

I posted a question about having the files in my root directory to the "getting started section". 

Share this post


Link to post
Share on other sites

:'( I did this tutorial and everything works well but i did this too:

- To create an image field called image_planet

- add this field to the template

- add one picture in the add page of EARTH, another in JUPITER

- choose a place into the template php file...

<img src="<?=$page->image_planet?>">

:'( It didn't work... (<?php echo ...... neither)

i was looking for the picture and the path of my picture... and it was tri-copied in weird folders with numbers in their names... ¿why 3 copies?

Thanks.

Share this post


Link to post
Share on other sites

There are likely a couple of issues with your code. If your images field has "Maximum files allowed" set to anything but "1", you would need to do:

$page->image_planet->first() because the images field is an array of more than one image.

Also, you need to supply the src with the url to the image, so you would need:

$page->image_planet->first()->url

It's all in the cheatsheet: http://cheatsheet.processwire.com/

and the images documentation: http://processwire.com/api/fieldtypes/images/

  • Like 2

Share this post


Link to post
Share on other sites

adrian and titanium, thanks a lot for the info.

I was looking for this kind of info in the forum, but the solutions i got were about Simply Gallery, and i thought they were talking about another way to show images.

About cheatsheet dictionary.. i am yet really newbie to understand it (of course my english is really bad to understand everything this wiki says).

I apologize for not having searched better. Sorry a lot

and again thank you.

Share this post


Link to post
Share on other sites

No need to be sorry. That is often made mistake (that still confuses me after 3 years). In my opinion it is bad design decision - probably only one there is in PW :) Simple and harmless setting that can break your site.

Not something I wish changed now, but I think it would be cleaner to always return array. Or maybe $page->images->url return url of the first image even if an array?

  • Like 2

Share this post


Link to post
Share on other sites

in this tutorial, we view the "jupiter" page via the admin interface....  how would that page be viewed via the front end?

<?php echo $page->title; ?> 

replace "title" with "jupiter"?

Share this post


Link to post
Share on other sites

the page would be accessed by it's URL;

the template markup would define what is presented on the page; you can echo any field on the template, or any field from any other page...

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.