Jump to:

23355 Posts in 17734 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Page Links error in FirstParagraph

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 2816 Views
  • EdP
    Avatar
    Community Member
    13 Posts

    Page Links error in FirstParagraph Link to this post

    If there is a link to another page on the site in the first paragraph of some Content, then:

    $Content.FirstParagraph outputs "[[sitetree_link id=n]]" where the link was, while

    $Content.FirstParagraph(html) outputs

    <a href="[sitetree_link id=n]">text-for-page-being-linked-to</a>

    I am using 2.4.1 and wonder if this is a bug.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Page Links error in FirstParagraph Link to this post

    Looks like the text isn't getting parsed by the shortcode parser as it should. Having looked at the code, this seems to be the case and you should probably file a bug for it.

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Page Links error in FirstParagraph Link to this post

    I just notice (and posted) about this happening within UserDefinedForms too (although the site is on 2.4.0)

  • EdP
    Avatar
    Community Member
    13 Posts

    Re: Page Links error in FirstParagraph Link to this post

    Thanks banal, thought so. Bug submitted:

    http://open.silverstripe.org/ticket/5969

  • prawnstar
    Avatar
    Community Member
    116 Posts

    Re: Page Links error in FirstParagraph Link to this post

    Just want to point out that this is happening with all html, not just the links.

    Any wysiwyg styling in the first paragraph is basically turned into bbcode.

    An external link to google outputs like:

    When I bold something it literally outputs * some text i wanted bold, but just has asterisks around it *

    EDIT:
    $Content.LimitWordCountXML(xxxx)
    Has the same issue.
    But...this all works fine inside the blog module.

    <% if BlogEntries %>
       <% control BlogEntries %>
          <% include BlogSummary %>
       <% end_control %>
    ...

    works as expected.

    C.b

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: Page Links error in FirstParagraph Link to this post

    Came across this issue similarly, in BlogSummary.ss none the links were being parsed correctly for $Content.FirstSummary.

    $Content.FirstSummary(html) along with the following tweak to /sapphire/core/model/fieldtypes/Text.php (Line 257):

    Replace

    return $data;

    With

    return ShortcodeParser::get_active()->parse($data);

    Dirty short term fix via a change to core folder to boot, nevertheless it fixed the problem for me while I wait for the issue to be resolved more broadly.

  • m-phil
    Avatar
    Community Member
    37 Posts

    Re: Page Links error in FirstParagraph Link to this post

    This doesn't work for me, I think it needs a higher priority than "middle"!
    It doesn't look nice - internal/external links and text highlighted bold for example.
    Any other suggestions?

  • figjam
    Avatar
    Community Member
    10 Posts

    Re: Page Links error in FirstParagraph Link to this post

    I solved this problem by post parsing my own rendered template.

    Page.php:

    class Page extends SiteTree {
       ...
       public function PageParseTemplate( $template ) {
        $data = $this->renderWith( $template );
        return ShortcodeParser::get_active()->parse($data);
       }
    }


    PreviewHolder.ss:

    <% control PreviewItems %>
       $PageParseTemplate(Preview)
    <% end_control %>


    The $ line above behaves just like <% include Preview %> with all the shortcodes resolved!

    2816 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.