Search

bbPress Showcase » bbPress Chat

Need help merging 2 functions

RSS

  1. Null
    User has not uploaded an avatar

    member
    Joined: May '08
    Posts: 43

    offline

    Hmm after investigating the problem some more, I think the Read More isn't the problem, but the "..." added after the filtered text. I'll try the \n\n solution there and if that doesn't work, I'll rewrite the function so it won't add the "..." and look if that solves anything.

    It would be a shame if I have to take out this whole Read More idea

    Posted 2 years ago #
  2. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    You wont have to take it out, you just have to figure out how to work around the bbPress post_text filters.

    Posted 2 years ago #
  3. Null
    User has not uploaded an avatar

    member
    Joined: May '08
    Posts: 43

    offline

    Unfortunately, nothing worked

    For now I've removed the "..." and put the Read More between <p> </p>.

    This doesn't fix the html, but the display is correct now.

    Till I figure out how to fix this (if it is possible at all) I'll have to do it this way

    Posted 2 years ago #
  4. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    Sorry I dont have the time to look at it right now.
    Note that you can also use &hellip; instead of three dots but I doubt that will solve anything.

    Posted 2 years ago #
  5. Null
    User has not uploaded an avatar

    member
    Joined: May '08
    Posts: 43

    offline

    No that doesn't change anything. It's just the filtered text that causes the problems. I have it running now whit out the dots and the problem still occurs.

    Very strange...

    Posted 2 years ago #
  6. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    You are adding the </p> before you apply the filter right?

    You might need to take a different approach and cut by LINES instead of words so that you don't truncate tags. Just a thought.

    The whole problem is that you are trying to cut text that already has html tags in it which is tricky.

    Another possibility would be to explode the text by ending p tags and simply use the first paragraph.

    $text=explode('</p>',$text);
    echo $text[1]."...</p>";
    Posted 2 years ago #
  7. Null
    User has not uploaded an avatar

    member
    Joined: May '08
    Posts: 43

    offline

    Hi,

    No I don't manually add the </p>, but I'll try your suggested code. I didn't know that every line is saved as <p>blabla</p>. Technically it isn't per line but per break/paragraph.

    Checking it now...

    Nope aint working, well I'll post the whole code I have now, so you can save it and check it yourself. Perhaps thats easier. Just activate and go to the newly appeared blog tab. Choose a forum where you want to pull the topics from, enter how many posts you want to see and the number of words. Go to the front page and there a link appears to your blog (under the Views part). Ow yeah you also need to add some css (no alpha build, normal build only) The css to be added is at the bottom of the script.

    Also I see that sometimes it aint counting right. If I set it to 30 it goes ok, at 31 it goes wrong badly and will count 31 +1...

    The link:
    http://pastebin.com/m2b0d9923

    Hope this helps, remember, I just started coding so it could be a bit messy

    Posted 2 years ago #
  8. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    The count is likely going wrong because of html tags in the code that you can't see but it's counting as words.

    You'll need some kind of "safety split" that will cut outside of html tags which is very hard to do. That's why I suggested lines instead but even that will have some quirks.

    Splitting on paragraphs should be the best bet if we can make the code work for you and then if the text is too short you can keep adding paragraphs until it's long enough.

    Posted 2 years ago #
  9. Null
    User has not uploaded an avatar

    member
    Joined: May '08
    Posts: 43

    offline

    Is it possible the explode the text, but ignore the HTML tags bbPress supports? Perhaps that will fix all problems. I don't know if bbPress has defined the HTML tags somewhere, but that could be used to ignore just the HTML.

    Just a wild thought.... I have no idea how to do this though

    Posted 2 years ago #
  10. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    You can use strip_tags() to remove all html tags from text before you explode it but I assumed you want to display the text with the tags (like bold italics, etc) so you can't (easily) have it both ways.

    But it does occur to me you could just remove any ending </p>

    Posted 2 years ago #

RSS feed for this topic

Post a reply to “Need help merging 2 functions” »

You must log in to post.

keep _ck_ coding >> donate $5 <<     Theme Switcher:
31 users online from in the past 30 minutes. 16 bots 14 guests 1 members: mccawphoto
7,605 views today 8,665 yesterday 14,010 peak. Most at once 63 today 48 yesterday 131 peak. Visited today: Dickinsonjohn9, shairah27, xiaotian, _ck_, engin1984, Augustine01, MichaelGomez, mccawphoto, KitchenDip
2,240 posts in 380 topics over 63 months by 425 of 1,992 members. Latest: shairah27, Augustine01, MichaelGomez