How to add first paragraph of one page as a block in home pa

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
CgullZ
New Member
New Member
Posts: 7
Joined: Thu Jan 10, 2013 7:34 am

How to add first paragraph of one page as a block in home pa

Post by CgullZ »

Hello,

I am new to cmsms and not sure where should I post my question, hopefully this is the right place.

I would like to redevlop a site I built with codeigniter.
The site I am trying to redevelop is: http://www.clunyanimaltrust.za.org

I would like to add the first paragraph from my About Us page to the home page with a Read more link that will of course open the About Us page.

Can you please direct me to the right place to read on how to do that?

Thank you
uniqu3

Re: How to add first paragraph of one page as a block in hom

Post by uniqu3 »

Linking to a page can be done with {cms_selflink} tag, for example {cms_selflink page='about' text='Read more'}

If you want to pull text automatically from About us page you can use CGSimpleSmarty module.
For example:

Code: Select all

{$cgsimple->get_page_content('about','content_en','short_content')} {* grab content from about page 'about' = page alias, 'content_en' = content block, 'short_content' = assigned variable *}
{eval var=$short_content|truncate:'100'} {* eval is used to process smarty tags as well, truncate to shorten text to 100 characters *}
{cms_selflink page='about' text='Read more'} {* link to page *}
CgullZ
New Member
New Member
Posts: 7
Joined: Thu Jan 10, 2013 7:34 am

Re: How to add first paragraph of one page as a block in hom

Post by CgullZ »

Thank you very much for the quick answer.

My home page code looks like this now:

Code: Select all

<p>Congratulations! The installation worked. You now have a fully functional installation of CMS Made Simple and you are <em>almost</em> ready to start building your site.</p>
<p>If you chose to install the default content, you will see numerous pages available to read. You should read them thoroughly as these default pages are devoted to showing you the basics of how to begin working with CMS Made Simple. On these example pages, templates, and stylesheets many of the features of the default installation of CMS Made Simple are described and demonstrated. You can learn much about the power of CMS Made Simple by absorbing this information.</p>
<p>To get to the Administration Console you have to login as the administrator (with the username/password you mentioned during the installation process) on your site at http://yourwebsite.com/cmsmspath/admin. If this is your site click <a title="CMSMS Demo Admin Panel" href="admin">here</a> to login.</p>
<p>Read about how to use CMS Made Simple in the {cms_selflink ext="http://wiki.cmsmadesimple.org/" title="CMS Made Simple Documentation" text="documentation" target="_blank"}. In case you need any help the community is always at your service, in the {cms_selflink ext="http://forum.cmsmadesimple.org" title="CMS Made Simple Forum" text="forum" target="_blank"} or the {cms_selflink ext="http://www.cmsmadesimple.org/support/irc" title="Information about the CMS Made Simple IRC channel" text="IRC" target="_blank"}.</p>
<h3>License</h3>
<p>CMS Made Simple is released under the {cms_selflink ext="http://www.gnu.org/licenses/licenses.html#GPL" title="General Public License" text="GPL" target="_blank"} license and as such you don't have to leave a link back to us in these templates or on your site as much as we would like it.</p>
<p>{$cgsimple->get_page_content('about-us','content_en','short_content')} {* grab content from about page 'about' = page alias, 'content_en' = content block, 'short_content' = assigned variable *}
{eval var=$short_content|truncate:'100'} {* eval is used to process smarty tags as well, truncate to shorten text to 100 characters *}
{cms_selflink page='about-us' text='Read more'} {* link to page *}</p>
And when I browse to the home page, all the styling is gone, and there is no Content from the About Us page and no Read more link.
Can you maybe help me a bit more? What am I doing wrong? ???
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: How to add first paragraph of one page as a block in hom

Post by Jo Morg »

uniqu3 wrote:If you want to pull text automatically from About us page you can use CGSimpleSmarty module.
CgullZ wrote:And when I browse to the home page, all the styling is gone, and there is no Content from the About Us page and no Read more link.Can you maybe help me a bit more? What am I doing wrong?
Did you install the CGSimpleSmarty module? It's not part of the initial install. ;)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
CgullZ
New Member
New Member
Posts: 7
Joined: Thu Jan 10, 2013 7:34 am

Re: How to add first paragraph of one page as a block in hom

Post by CgullZ »

Yes, I did install the module :)
CgullZ
New Member
New Member
Posts: 7
Joined: Thu Jan 10, 2013 7:34 am

Re: How to add first paragraph of one page as a block in hom

Post by CgullZ »

UPDATE:

I checked again and the module was not installed, although I don't know why.

I went to Module Manager/Available Modules

Clicked on Download and Install for the module and did get the success message, so not sure what happened there.

So now the home page has the styling, and I see a static text: "Read more" but it's not a link, and there is no content from the About Us page displaying.

Another questions is what if I don't want to limit it to 100 characters, I want the first paragraph from the about us page.
What if tomorrow this paragraph will change to 200 characters? Is it possible to get the paragraph not by limiting characters?

Just a thought, can I maybe do that by adding a global block called teaser and refference this block in the code? Am I on the right path?
CgullZ
New Member
New Member
Posts: 7
Joined: Thu Jan 10, 2013 7:34 am

Re: How to add first paragraph of one page as a block in hom

Post by CgullZ »

Ok, don't know what happened to my reply.

Trying again.

I did install the module, but somehow although I saw the success message, checking again said the module is not installed.

Anyway, it is installed now.

Now I see the Read more text but is is not a link and there is no content displayed from the About Us page.

I changed the

Code: Select all

{content_en}
tag to

Code: Select all

{content}
Now the Read more is a link, but still no content from About Us displayed.

Another question is how do I display the first paragraph of the About us page and not 100 characters. Is that possible?

I looked at global blocks and user tags but it doesn't look like it can help my case.

I need to have another field in the Create page form that is called Teaser and this field is the one that should be displayed on the home page.

Hope I make sense... Is there a way to do that? Is it a module I need to develop maybe?
CgullZ
New Member
New Member
Posts: 7
Joined: Thu Jan 10, 2013 7:34 am

[SOLVED]How to add first paragraph of one page as a block

Post by CgullZ »

Yay, I've made it !!!

If anyone else is interested, I have added this line in my template:

Code: Select all

{content block='teaser'}
That added another field to my page when creating/editing it.

Then I changed the Home page code to:

Code: Select all

{$cgsimple->get_page_content('about-us','teaser','short_content')} {* grab content from about page 'about' = page alias, 'content_en' = content block, 'short_content' = assigned variable *} {eval var=$short_content} {* eval is used to process smarty tags as well, truncate to shorten text to 100 characters *} {cms_selflink page='about-us' text='Read more'} {* link to page *}
And there we go...

Have to say - that WAS simple.

Now I need to find out how to keep the '->' characters when a user updates the home page, as it chages to > when the page is saved.

Thank you for the help :D
uniqu3

Re: How to add first paragraph of one page as a block in hom

Post by uniqu3 »

You should not use WYSIWYG for smarty code with logic, it is basically bad practice creating any kind of logic in area editable by user.

Either do that logic in your site template or use a GCB (Global Content Block), disable WYSIWYG (there is checkbox on top) for that GCB and just call {global_content name='THE_NAME_OF_GCB'} in your WYSIWYG area.
CgullZ
New Member
New Member
Posts: 7
Joined: Thu Jan 10, 2013 7:34 am

Re: How to add first paragraph of one page as a block in hom

Post by CgullZ »

Aha ! Thank you :)
Post Reply

Return to “CMSMS Core”