Shor intro on Homepage, Full intro on about us page

5 posts by 3 authors in: Forums > CMS Builder
Last Post: November 28, 2011   (RSS)

By jacgo - November 27, 2011

Hi, there

My about us page is "about_usDetail.php"
I would like have 4-5 lines shor about us content on Homepage "index.php"

When click "more detail..."
User can go "about_usDetail.php" for full information.

1) How to do the above issue?
2) Can I choose which paragraph for Homepage?

Thanks for help!

Jacgo

Re: [gkornbluth] Shor intro on Homepage, Full intro on about us page

By jacgo - November 28, 2011

Thanks for the quick reply.

I don't know how to post short intro on my Homepage from my "about_usDetail.php" page.

is there any one who know how to do?

Many thanks!

-jacgo

Re: [jacgo] Shor intro on Homepage, Full intro on about us page

Hi Jacgo,

You can display the contents of any text box field on any of your pages.

The maxwords function will limit the amount of words that show on your home page, and should give you the result that you want.

If you need more help, please be specific about what you've tried, what works, what doesn't, what code you've used, and what errors, you get if there are any.

I'm assuming that your "about" page gets its information from a single record editor field.

In your home page code, at the top, inside the PHP that loads the records for that page, you need to insert a load records call that looks like this, except that it has your about table name inserted.

// load records
list($your_about_tableRecords, $your_about_tableMetaData) = getRecords(array(
'tableName' => 'your_about_table',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$your_about_tableRecord = @$your_about_tableRecords[0]; // get first record


Next, at the top of the body code of your page, you would insert the function that makes maxwords work.

<?PHP
function maxWords($textOrHtml, $maxWords) {
$text = strip_tags($textOrHtml);
$words = preg_split("/\s+/", $text, $maxWords+1);
if (count($words) > $maxWords) { unset($words[$maxWords]); }
$output = join(' ', $words);

return $output;
}
?>


Then, in the body code, where you wanted the short intro from the about page to appear, insert this code, change the table name and field name to your names. Change the 5 to any number of words that you want to appear.
<?PHP echo maxWords($your_about_table['content'], 5);
?>...<a href="<?php echo $record[your_about_contents_field']; ?>”>Read More</a>


It sounds like you're pretty new at PHP coding for CMSB. My CMSB Cookbook http://www.thecmsbcookbook.com has a step by step beginners guide that can help you understand more about the process.

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [jacgo] Shor intro on Homepage, Full intro on about us page

By Damon - November 28, 2011

Hi Jacgo,

The most simple solution is to create another textbox field in your About Us section editor in CMS Builder just for the homepage content.

You could call it Intro About Us, for example, and add it as a textbox field.

Add your content that you want to have appear on the homepage. Then add the publish code for that field to the homepage template and a link under that back to the About Us page.

How does that sound? Let me know if you have any questions or need more details.

Thanks!
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/