mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Fixed SiteTree->Content link shortcode parsing introduced in r101093 (#5227)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101302 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
3fd6d47e86
commit
3e8b155557
@ -245,7 +245,7 @@ class ViewableData extends Object implements IteratorAggregate {
|
||||
* @return string
|
||||
*/
|
||||
public function castingHelper($field) {
|
||||
if($this instanceof DataObject && ($fieldSpec = $this->db($field))) {
|
||||
if($this->hasMethod('db') && $fieldSpec = $this->db($field)) {
|
||||
return $fieldSpec;
|
||||
}
|
||||
|
||||
@ -441,6 +441,7 @@ class ViewableData extends Object implements IteratorAggregate {
|
||||
*/
|
||||
public function XML_val($field, $arguments = null, $cache = false) {
|
||||
$result = $this->obj($field, $arguments, false, $cache);
|
||||
|
||||
return is_object($result) ? $result->forTemplate() : $result;
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,25 @@ class ContentControllerTest extends FunctionalTest {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testLinkShortcodes() {
|
||||
$linkedPage = new SiteTree();
|
||||
$linkedPage->URLSegment = 'linked-page';
|
||||
$linkedPage->write();
|
||||
$linkedPage->publish('Stage', 'Live');
|
||||
|
||||
$page = new SiteTree();
|
||||
$page->URLSegment = 'linking-page';
|
||||
$page->Content = sprintf('<a href="[sitetree_link id=%s]">Testlink</a>', $linkedPage->ID);
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
|
||||
$this->assertContains(
|
||||
sprintf('<a href="%s">Testlink</a>', $linkedPage->Link()),
|
||||
$this->get($page->RelativeLink())->getBody(),
|
||||
'"sitetree_link" shortcodes get parsed properly'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user