Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Shor intro on Homepage, Full intro on about us page

 

 


jacgo
User

Nov 27, 2011, 7:09 PM

Post #1 of 5 (873 views)
Shortcut
Shor intro on Homepage, Full intro on about us page Can't Post

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


gkornbluth
Veteran

Nov 27, 2011, 8:14 PM

Post #2 of 5 (866 views)
Shortcut
Re: [jacgo] Shor intro on Homepage, Full intro on about us page [In reply to] Can't Post

Hi Jacgo.

It's pretty easy using a something called a function on your home page.

Here's a portion of a recipe from my on-line CMSB Cookbook http://www.thecmsbcookbook.com that describes the code you'll need and how to implement it.

Hope it helps,

Jerry Kornbluth

MAXWORDS - LIMITING THE NUMBER OF WORDS SHOWN ON A PAGE

NOTE: You'll have to load the table required (your about page) with a load records call at the top of your home page, and if your about page is a single record editor, you'll have to change the occurrences of $record in the example to $your_about_page_tableRecord.

If you use the character limiting function that’s exactly what you’ll get, and words can be cut off. But if you want to limit the word
count, Dave Edis from Interactive Tools shares his usual uncanny wisdom:

Insert this function at the top of your page, or before you want to invoke the word limiting function:


Code
<?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 put this code where you want the words limited to 5 words in this example:

Code
<?PHP echo maxWords($record['content'], 5); 
?>

If you want to add ...more and a link, use something like this:

Code
<?PHP echo maxWords($record['content'], 5); 
?>...<a href="<?php echo $record['_link']; ?>”>Read More</a>


or


Code
<?PHP echo maxWords($record['content'], 5); 
?>...<a class="read-more" href="http://www.your_site.com/your_detail_page.php?<?php echo $record['num'] ?>">(Read More)</a>

The first CMS Builder reference book is now available on-line!
http://www.thecmsbcookbook.com

(This post was edited by gkornbluth on Nov 27, 2011, 8:15 PM)


jacgo
User

Nov 27, 2011, 9:49 PM

Post #3 of 5 (847 views)
Shortcut
Re: [gkornbluth] Shor intro on Homepage, Full intro on about us page [In reply to] Can't Post

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


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.


Code
 // 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.


Code
<?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.

Code
<?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


Damon
Staff / Moderator


Nov 28, 2011, 9:31 AM

Post #5 of 5 (810 views)
Shortcut
Re: [jacgo] Shor intro on Homepage, Full intro on about us page [In reply to] Can't Post

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/