
gkornbluth
Veteran
Nov 28, 2011, 6:01 AM
Post #4 of 5
(812 views)
Shortcut
|
|
Re: [jacgo] Shor intro on Homepage, Full intro on about us page
[In reply to]
|
Can't Post
|
|
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! http://www.thecmsbcookbook.com
|