Creating a ModX website part 4: Improving the masthead
published onFor now we only have one page which displays a masthead for a single person. In this part I will describe a slightly different way of doing things which would help you create new pages for other people and for you not to have to rewrite them from scratch.
Remember, that this part of the series only deals with changing the masthead. In reality the about and portfolio sections would need updating too.
Updating the home page
The first thing to do is to update the home page with a name. To do this remove the [[$masthead]]
tag from the BaseTemplate
and replace it with [[*content]]
. Now make sure to add the [[$masthead]]
tag in the content section of the home page.
What the [[*content]]
tag does is replace the tag in the template with whatever is found in the content section of the relevant page in the Resources
tab.
If you viewed your web page now everything should look just the same as it always has.
Adding your name
We want to replace the START BOOTSTRAP
string on the web page with our own name.
To do this open the masthead chunk, find the h1
section with the text Start Bootstrap
and replace it with [[+name]]
. Make sure to save.
Go back to your home page and change [[$masthead]]
to read [[$masthead? &name=`User one`]]
. Be aware that those are backticks either side of the name.
Viewing your site now should display your own name under the image.
Developing the site
If you were only going to use this site for one person then this would probably be overkill so far.
However, now we are going to benefit from the power of ModX by creating a second page by clicking on the +
icon next to the word Website
, filling in a page title and then adding in the following [[$masthead? &name=`The Newbie`]]
tag.
Once you save your work so far you can click on the View
button in the top - right to view this new page. You should see the name change to The Newbie
.