6. Creating Pages

6. Creating Pages


– [Instructor] In our
simple site, I’ve decided that editors won’t be able to add new pages to the main navigation. The one place they’d
like to be able to create new pages, as it requires them, is inside the About section. In this video, I’m going to
create my main About page and then create a master
page from which other pages in the About section can be created. I’ve saved my About HTML
page into a new folder called About, and I’ve
saved that as Index.php. I’ve already included Perch on the page, and I’ve made sure that
the path is correct because we’re now inside a subfolder. I’ve added two Perch regions to this page. One is the masthead area. And another is for some content. I’ve created a new template
for this masthead area because I’ve got some
specific markup I want to use, and I’m just using the default
text area for the content. And if we look at a browser, you can see we’ve got the
masthead and the content, which in the admin is the masthead there, and some content. The design allows for subpages. We can seem them here in the navigation, so let’s set this up. The first thing that I need
to do is create a master page. This is kind of a special
kind of full-page template which new pages are based on. And we can use our About Index.php as a template for this. So I’m going to take this Index.php, and I’m going to save it into Perch, Templates, Pages, and I’ll call it About.php. Now if you look in Perch Templates Pages, you’ll see that we also
have a Default.php. Open up Default.php, and we’ll use this to help us create our master page. The first thing you want is to copy out this link to the run time. It looks a bit different, because we don’t necessarily
know the entire path to the run time when we’re creating a page from a master page. So if we go to About and go
up to where our run time is and just replace that with that statement. Next you can see we’ve
got this word About here. What I want to do is
make this so it picks up the page title rather
than just saying About for all pages created
from this master page. So I’m gonna delete that. And I’m going to add
another Perch function. This is Perch Pages Title. Finally, I want to be able to
navigate to these new pages, so I want to add them
to the surf navigation. If we go down here, we
can see we’ve got this in this section area. So I’m going to take out this navigation, and I’m going to add a
little bit of php here. When you add any php to a page, you need to put it inside these php tags. And we say Perch Pages Navigation. So that’s the Perch Pages
Navigation function. And inside that we can put an array. And that array needs to have a from path. And the path is About,
because this is the section that we want to show pages from. And how many levels? Well let’s just say one. And that’s it, we can save this page now. Now because we’re making
a copy of our About page, we’d like that to have
the navigation on too. I’m just gonna take
this navigation section and I’m going to go and find my About Index.php,
and I’m gonna find that in this section navigation again. And I’m just gonna pop that there too. And these arrays that you see here, pretty much all the php
you need to add in Perch is very simple, and probably
the most complex thing you need to do is to
create one of these arrays to set options for a Perch function. So you’ve become quite
familiar with seeing these and understanding how to
change the different options as you build up your pages with Perch. That really is about as
complicated as it gets. Now when you create a new page with Perch, it creates an actual
physical file on disk. That’s a difference
between Perch and Runway. Runway doesn’t do that, it
creates pages in the database, but with Perch you’re actually
creating a page on disk, and that means that you need to have your About section of the site
writable by the web server. It may well be by default, or
if you set to the same thing that you’ve got your
Resources section set to, that will work as well. So now we can start to
create a page with this, so we want to go the Master Pages section, and you can see the default. You can also see our About. And you can see it’s got a title. See Copy Regions From,
now if you’d like to copy the regions from another
page, you can do this here. Now, we’ve already set up
regions on our About page, and the subpages because
they’re copied from that About page, we’d like
to have the same regions. This means that when your content editor creates a new page, the page will already have the regions preselected. They won’t need to choose
which template to use, which is probably what you want. So let’s say copy regions for About. And new pages should reference
this master page or copy it. Now this is important. If you say reference,
it means you can go back and you can make changes
to your master page and they’ll be reflected in all of the pages created from it. That’s probably what you want. If you want pages to
be completely detached from the master page, you can
say copy this master page. Generally, I’d say reference
because it’s useful to be able to make changes to
the HTML on your master page, and it go on to all of the
pages that are created from it, so that’s what we’ll do here. So we’ve now set up that master page. So now if we go out to Pages, see About, and we can say new subpage. So parent page is About,
and the master page, we can choose About. So let’s say Our History. Now history in these will be pre-filled, or you can change them if you want. Then you can hit Submit. And if we go to Regions, you can see that we’ve
already got the masthead and the content already filled in. So we can give some content here. And this would be the page content. And if we return to About, and reload, you see it is in this
section, Our History, that’s our navigation working. And we click on that,
and this is our new page that we’ve created, and
you can see that the title, which is showing up in
the tab, says Our History. So that’s the function that
you added to create the title. So now you can create your About section and you can add different pages in there to build up that section
based on a master page. And because we’re
copying the same regions, your content editor
doesn’t have to worry about which template to select. It’ll all be preselected for them, and they can just get
on with adding content.

Comments

  1. Post
    Author

Leave a Reply

Your email address will not be published. Required fields are marked *