Parsing Markdown inside the CMS Gridfield #5

Open
graphicagenda opened this Issue Aug 19, 2012 · 3 comments

Comments

Projects
None yet
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

This comment has been minimized.

Show comment
Hide comment
@graphicagenda

graphicagenda Aug 19, 2012

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

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

@wolfv

This comment has been minimized.

Show comment
Hide comment
@wolfv

wolfv Aug 19, 2012

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

:)

Owner

wolfv commented Aug 19, 2012

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

This comment has been minimized.

Show comment
Hide comment
@graphicagenda

graphicagenda Aug 20, 2012

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

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