EDIT:
My objective:
- Create a news page template with header and footer and body.
- The news page needs a form for a content editor to add content to with two fields: Headline and story.
- Each news page requires its own SEO meta data (keywords / description title).
- These stories need to be easy to find within the CMS for future editing etc etc.
What is the best way of going about this?
What I currently have is a “Page” content-type which has all the form fields I require.
To create a new news item, I currently do:
- Go to Site Browser
- Right-Click [myFolder]
- Click “New” –> Page
- Choose my page from the select box (that was the page content-type I created earlier)
- I now see my form, fill it in and save/publish and I see it, but with the issues I expressed before.
I am pretty sure I am going about this in the wrong way, but what is the right way?
————-
I am struggling to create a very basic page in dotCMS.
Here is what I want to do:
- Create a form for a content editor to be able to add content to the page (Content-Type: Page called “myForm”) DONE
- The form contains all the default fields (seo stuff etc that comes with the Page content-type) + two extra text fields I have created (fieldA and fieldB) DONE
- Create a container and add in the velocity variable names. DONE
- Surround the velocity variable names in some HTML.
<div>$fieldA</div>
and<div>$fieldB</div>
DONE - Create a new theme with a template.vtl file DONE
So that is all set up. I now go and create a new page in a folder via Site Browser choosing my new “Page” called “myForm” from the drop down menu. I see my form and enter my data, save and publish.
Result. I dont see any of my data. Just a blank page.
So I check the docs and see what I have missed.
There is a page explaining that I need to add in some velocity into my template.vtl that looks like this:
#if($dotPageContent && $dotPageContent.fieldA)
<div class="row">
#dotedit($!dotPageContent.inode,$!dotPageContent.fieldA)
</div>
#end
#if($dotPageContent && $dotPageContent.fieldB)
<div class="row">
#dotedit($!dotPageContent.inode,$!dotPageContent.fieldB)
</div>
#end
OK, so now when I check my page again, the data is indeed being displayed. But there is a problem. The HTML that is in my container does not get parsed.
E.g. <div>$fieldA</div>
and <div>$fieldB</div>
does not have the <div></div>
tags.
So now I’m worried this is not the way to create pages.
The reason I chose the “Page” content-type was that it comes ready to go with the “Advanced Propertied” for the page like SEO meta data (which by the way all worked fine).
Can someone point out what I may have missed or perhaps a better way of going about this?
Thanks in advance.
2
Answers
If you could post your container and template code somewhere and include the links here I could help you resolve the issue for sure, but I think what might be happening is that you are confusing the Page Content Type with the Container defined Content Types.
Here is a quick explanation that might help conceptual differentiation:
http://screencast.com/t/PlEXKU9glGd
What I explain in the video is that the Page Content Types are for page properties only – not content addition. Like you want a different facebook link on many of your pages, or some other special property tied to each page. To place content in a container, you use a secondary “Content” Content Type, and you add that content type to a container’s code field. When a page loads, the execution happens in this order, the Page content loads, page properties and metadata are set, the page calls a template that provides the layout, the template calls containers, the containers have the code that formats the content, and then the content executes in the order that it is placed in the container by the content publisher. The Page content type is not intended to really provide any information that the front end user actually sees other than the Page Title, page url, and properties and metadata that are set “silently” in the background html of the page.
You also might find it helpful to join the dotCMS communty forum: http://dotcms.com/forum/
Hope that helps
In addition to my other post, I did do the test with what you were trying to to, in a test advanced template, and the template.vtl file does display the Page Content, as long as you actually edit your page properties and set, in this case, field A:
This was tested on demo.dotcms.com: U:[email protected] / P: admin