How can I load the body text into a template?

Permalink
Hi there

Is there an easy way to load the body text from the COMPOSER into a template – there's this page title add-on, something like this for the body text?

Many thanks
Simon

 
Parasek replied on at Permalink Reply
Parasek
There are few ways you can do it:

1) First way (using Content block)

Go to page
Dashboard/Page & Themes/Page Types
/dashboard/pages/types

Click "Edit form" in the row of your page type

Hover Set name, click plus icon, add Block/Content

Go back to /dashboard/pages/types

Click "Output" button

Click "Edit Defaults" of page type that you are using in composer

Now click "Add content"

In the list on the left, at the bottom there is "Composer control". Add this like normal block to your "Main" area
Select "Content"
Now "Exit edit mode"/"exit edit defaults".

Now, every time you add new page using composer, there will be "Content" area that will be automatically inserted into "Main" area.

--------------------------------------------


2) Second way (using Page atribute)

Go to page
Dashboard/Page & Themes/Attributes
/dashboard/pages/attributes

Add atribute "Text area" (at the bottom)

Set handle and name, for exaample:
content, Content
Change Input Format to "Rich Text - Default Setting".
Click "Add"

--
How to add it manually:
Return to page, which you want to edit.
Enter edit mode, click "Add Content"
In Multimedia group there is "Page Atrtibute Display". Add it to "Main" area.

Select "Property to Display:"
Choose Page Attributes/Content

Of course, you also need to edit page attribute: "Page settings"/"Attributes"/find "Content" and add some text.

--
How to add it in composer:
Go back to /dashboard/pages/types
Click "Edit form"
Hover Set name and click plus icon.
Click "Custom attributes"/"Content"

Go back to /dashboard/pages/types
Click "Output"
Now, instead "Composer Control" add "Page Attribute Display".
Select "Page attributes/Content".
Exit "edit mode" and go back to /dashboard/pages/types

Now every time you add page, c5 will automatically put "Page Attribute Display" into your "Main" area (with text you entered in composer).


--------------------------------------------

3) Third way (requires editing .php file and some technical knowledge).
It's not advised if you are using core/marketplace theme. Rather if you are developing your own custom theme.

Add "Content" (handle: content) attribute to c5 and to composer like in 2)

Now find .php template file on your server, which you are using.
Above or below "Main" area add code

if (!empty($c->getAttribute('content')) {
   echo $c->getAttribute('content')
}


It will display "Content" page attribute
eivissa89 replied on at Permalink Reply
THANK YOU! That's just awesome!
Thank you very much!

No. 2 worked well for me...
If you had two languages would you do it separately (each page) or somehow in the same page attributes or in the composer?

Thanks again!
Parasek replied on at Permalink Reply
Parasek
1 composer page, 1 attribute. And just create two different pages in different locations.
eivissa89 replied on at Permalink Reply
good, thanks!

now there is the problem that the page list loads the description instead of the content box we made new... I guess it's possible to change that as well?!
Parasek replied on at Permalink Reply
Parasek
Pagelist will always display page description (only text) as default. You would need to create new pagelist template and display your new attribute instead.
eivissa89 replied on at Permalink Reply
Would you know how to create this new template and load it?

thank you!
Parasek replied on at Permalink Reply
Parasek
Copy existing template to application/blocks/page_list/templates/your_template_name.php

Existing template can be found in:
concrete/blocks/page_list/view.php (or any php file/folder in "templates" folder)
or
application/themes/your_theme_name/blocks/page_list/view.php
or
packages/package_name/blocks/page_list/view.php
or
updates/c5_version/concrete/blocks/page_list/view.php

Which one, it depends if you are using core template/custom template/template from package or if you upgraded c5.

After you modified "your_template_name.php", change your block template in CMS (enter edit mode, left click pagelist block, select "Design & custom template", select "Your template name"