Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Page Links error in FirstParagraph


Go to End


10 Posts   6015 Views

Avatar
EdP

Community Member, 14 Posts

2 September 2010 at 2:38am

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.

Avatar
bummzack

Community Member, 904 Posts

2 September 2010 at 2:50am

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.

Avatar
swaiba

Forum Moderator, 1899 Posts

2 September 2010 at 3:15am

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

Avatar
EdP

Community Member, 14 Posts

2 September 2010 at 3:20am

Thanks banal, thought so. Bug submitted:

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

Avatar
digibrains

Community Member, 130 Posts

5 September 2010 at 8:49am

Edited: 05/09/2010 11:10am

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:

google.com[http://www.google.com]

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

Avatar
dizzystuff

Community Member, 94 Posts

26 September 2010 at 9:53pm

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.

Avatar
m-phil

Community Member, 37 Posts

21 January 2011 at 11:57pm

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?

Avatar
figj

Community Member, 12 Posts

9 February 2011 at 10:31pm

Edited: 09/02/2011 10:34pm

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! :-)

Go to Top