Create a dynamic "Details" link in user content using php

Hopefully the title can explain a little of what I want to accomplish. So I have a CMS user system and basically have a normal WYSIWYG (tinymce) where users can write their blog posts. I looked at a fragment of the page, but I could not find anything past, “you need to write this functionality yourself”, so my first thoughts were to add two more text areas, but that would be too convenient.

then I thought well if there is something that can be added to wysiwyg:

<span id='break1"></span>

I could use php or jquery or whatever you turn this code into a link and then take care of the rest using the htaccess file to work with the url.

I am largely out of ideas on how to handle this, so any information, thoughts on this will be greatly appreciated.

here is an example of what it should do:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<a href="/seo-title/2/">read more</a>
<!-- people would not see this part until the 'read more' link was clicked. -->
<!-- will open a new page NOT just hidden content -->
<p>Duis scelerisque, in tempus ante tortor eget tortor. Donec eu consequat augue.</p>
+3
source share
4 answers

If I understand correctly, you want to generate this in php and process the read more in javascript (specifically jquery). I wrote a basic snippet that you can use.

<p><?php echo substr(CONTENT,0,255); ?></p>
<?php if (strlen(CONTENT) > 255): ?>
    <a class="readmore">read more</a>
    <p class="more"><?php echo substr(CONTENT,256); ?></p>
<?php endif; ?>

javascript will look something like this: quick jump.

var $readmore = $('.readmore');
$readmore.bind('click',function(){
    var $next = $(this).next('p');
    $next[$next.is(':visible') ? 'hide' : 'show']();
});
+4
source

The way I do this for a resume on my blog uses a comment:

<! - more →

Then I have a function to get only a summary of the blog post:

$i = strpos($contents, '<!--more-->');

if ($i !== false) {
    $i += strlen('<!--more-->');
    return substr($contents, 0, $i);
}
else return $contents;
+2
source

, , , , , , - , , - , , sql .

get:

<a href="fullpost.php?id=<?php echo $id; ?>" target="_blank">Read More</a>

Michael substr, , .

, , , , - , , , ajaxing , - , , .

, , , .

+1

, ... " " -, ? ?!

<a href="javascript:void(0);" onclick="jsFunction()">read more</a>

jsFunction () is a placeholder for displaying a p-tag. What do you want, so to speak, with the span element :-)?

0
source

All Articles