HOW TO create my own readmore button? (Advanced Ed.)

Discuss everything related to ApPHP MicroBlog. Any questions related to developing or using should be posted to this forum.

Moderators: ne_moj, alexmst, zewa, ICap, vadimako, ne_moj, alexmst, zewa, ICap, vadimako

rodger
Newbie
Newbie
Posts: 3
Joined: Oct 13th, '11, 16:58

HOW TO create my own readmore button? (Advanced Ed.)

Postby rodger » Oct 13th, '11, 17:02

Hi everybody,
I've just installed and tested microblog i'ts just perfect for my use but one question :

Is there a way to create a button read more not locked with "Maximum post length ", something like {readmore} put in the post?

If someone have done this or have any idea, let's go!!

Thanx
Last edited by rodger on Oct 21st, '11, 12:37, edited 1 time in total.

rodger
Newbie
Newbie
Posts: 3
Joined: Oct 13th, '11, 16:58

Solution

Postby rodger » Oct 14th, '11, 14:03

IN Admin : settings/formatting put what you want in "Maximum post length "

THEN
in include/classes/Post.class.php find :

if(strlen($post_text) > $max_post_length){
$post_text = substr_by_word($post_text, $max_post_length);
if($str[strlen($post_text)-1] != ".") $post_text .= ".";
$post_text .= "<br><div class='read_more'><img src='images/read_more.png' alt=\""._CLICK_TO_READ_MORE."\"> ".prepare_link("posts", "post_id", $posts[0][$i]['post_id'], "read_more", _READ_MORE."...", "read_more_link")."</div>";
}

AND REPLACE WITH :

// Hack READ MORE
$part1 = "";
$part2 = "";
list($part1, $part2) = explode("{readMore}", $post_text);
if ( $part1 == "" OR $part2 == ""){
} else {
$readmore[$i] .= "<div class='read_more'>".prepare_link("posts", "post_id", $posts[0][$i]['post_id'], "read_more", "<span>Read more about ".$posts[0][$i]['post_title']."</span>", "read_more_link")."</div>";
$post_text = $part1.$readmore[$i];
}

+ AFTER :

if(preg_match("/{module:contact}/i", $post_text)){
if(!@$objLogin->IsLoggedIn()){
$post_text = preg_replace("/{module:contact}/i", $objContact->DrawContactForm(), $post_text, 1);
}else{
$post_text = preg_replace("/{module:contact}/i", "", $post_text, 1);
}
}

PUT :
// HACK HISTORY BACK
if(preg_match("/{readMore}/i", $post_text)){
list($part3, $part4) = explode("{readMore}", $post_text);
$historyBack .= "<a class='buttonBack' href='javascript:history.back()'>Back</a>";
$post_text = $part4.$historyBack;
}

NOW when you writte a post, just have to put {readMore} in it, where you want the post to be cut and that's all.

I just need help to change the link created for the "read_more" button wich is uggly not SEF. read-more.html for all posts is not good.
Should be something like :
/categories/name-of-categorie/title-of-post.html

I don't understand "prepare_link"

$readmore[$i] .= "<div class='read_more'>".prepare_link("posts", "post_id", $posts[0][$i]['post_id'], "read_more", "<span>Read more about ".$posts[0][$i]['post_title']."</span>", "read_more_link")."</div>";

Any idea?

rodger
Newbie
Newbie
Posts: 3
Joined: Oct 13th, '11, 16:58

HOW TO create my own readmore button?

Postby rodger » Oct 21st, '11, 12:37

To have a good SEF url in the read more link, change the line $readmore[$i] .= in my HACK with this one :

$readmore[$i] .= "<div class='read_more'>".prepare_link("posts", "post_id", $posts[0][$i]['post_id'], $posts[0][$i]['post_title'], "<span>Read more about ".$posts[0][$i]['post_title']."</span>", "read_more_link")."</div>";

Now it's ok!


http://www.woblog.fr

Don't hesitate with the "like FB".... if you do... I feel a little bit alone in this forum....


Return to “ApPHP MicroBlog Talk {developers/users}”