Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Parsing Markdown inside the CMS Gridfield #5

Open
graphicagenda opened this Issue · 3 comments

2 participants

@graphicagenda

The way I was able to parse text while viewing the gridfield is like so. I was hoping an easier way (without require statements), but it works in my test enviro.
I made this an issue, so that someone could clear this as working for others.

        $config = GridFieldConfig_RelationEditor::create()->addComponents(
            new GridFieldSortableRows('SortOrder')
        );
        $f = new GridField('Testimonials', 'Book Testimonials', $this->Testimonials(), $config);
        $f->getConfig()->getComponentByType('GridFieldDataColumns')->setFieldFormatting(array( 
                        "Title" => function($obj) {
                             require_once(BASE_PATH.'/markdowneditorfield/code/lib/markdown/markdown.php');
                             require_once(BASE_PATH.'/markdowneditorfield/code/lib/markdown/markdown_extended.php');
                             return MarkdownExtended($obj); 
                        })); 
        $fields->addFieldToTab('Root.Testimonials', $f);
@graphicagenda

Actually, the question is how to bring the function($obj){} outside setFieldFormatting() and formatting the other columns at once

@wolfv
Owner

Hey,

do you know about getters and setters? Maybe you can do it with them: relevant DOC entry: http://doc.silverstripe.org/framework/en/topics/datamodel#properties

:)

@graphicagenda

Thank you, I will update the issue with the right getter function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.