Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Cutting a blog entry down for front page
Old 10-24-2007, 05:47 PM Cutting a blog entry down for front page
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
Ok I have a blog that I've been working on for a couple weeks but I can't figure out how I would insert a tag such as <!--break--> into the blog entry and make it only display up to that <!--break-->. Anyone have any ideas?
XBSHX is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-25-2007, 06:55 AM Re: Cutting a blog entry down for front page
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
I think what your looking for is the substr() function.

PHP Code:
echo substr('$blogpost'0200);  // all the letters between 0 and 200.
echo "..."
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 10-25-2007, 08:22 AM Re: Cutting a blog entry down for front page
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
Good idea Mike, but I think I know of a better way:

PHP Code:
$input "Some really long <!--break--> bit of text";
$changed explode("<!--break-->",$input,2);
echo 
$changed[0];
echo 
"..."
That way you don't need to know the length, just to put in a break where you want it to break.

Hope that helps!
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Old 10-25-2007, 09:48 AM Re: Cutting a blog entry down for front page
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Ah, smart

I guess I did not read the whole post

You could also use a preg. But I think in this case, it does not matter.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 10-25-2007, 12:20 PM Re: Cutting a blog entry down for front page
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
I don't think it does.

You way was good of course, if you know how many characters you want; eg in a list or something. It's about horses for courses I guess.
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Old 10-25-2007, 07:42 PM Re: Cutting a blog entry down for front page
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
Thanks for the help guys, I actually figured it out shortly after posting this.

Heres the function I made to do it.

PHP Code:
function blogBreak($blogpost) {
    
        
// Set the symbol for the break
        
$break '<!--break-->';
        
        
// Find where the break is in the blog post
        
$position strpos($blogpost$break);
        
        
// Subtract only up to the break
        
$blogshort substr($blogpost0$position);
    
        return 
$blogshort;
    
    } 
XBSHX is offline
Reply With Quote
View Public Profile
 
Old 10-25-2007, 07:48 PM Re: Cutting a blog entry down for front page
jamestl2's Avatar
No scale-itch here...

Latest Blog Post:
Wordpress Relative URLs Plugin
Posts: 2,389
Name: <member type="brilliant" alt="foolish">James Lewitzke</member>
Location: / public_html / Universe / Virgo_Supercluster / Local_Group / Milky_Way / Orion_Arm / Solar_System / Earth / North_America / USA / Wisconsin
Trades: 0
When I write a blog post in wordpress, I can cut off what I say with a <!--more--> tag, if that's your blogging software.
__________________
Engipress -
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
for Wordpress Projects
jamestl2 is offline
Reply With Quote
View Public Profile Visit jamestl2's homepage!
 
Old 10-25-2007, 07:54 PM Re: Cutting a blog entry down for front page
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
I'm actually using custom blog software that I created.
XBSHX is offline
Reply With Quote
View Public Profile
 
Old 10-26-2007, 10:26 AM Re: Cutting a blog entry down for front page
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
If it works, great. I still stick by my method, which is a tad simpler

Good for you for working it out though.
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Reply     « Reply to Cutting a blog entry down for front page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28227 seconds with 12 queries