How do I make a custom markItUp preview page in PHP?
Asked Answered
K

1

5

I have a question about markItUp!'s preview function.

Inside jquery.markitup.js i have these settings:

previewTemplatePath:'~/templates/preview.php',
previewParserPath:'~/templates/preview.php',
previewParserVar:'data'

I'm not sure what to do with previewParserPath and previewParserVar. Is it possible to grab the content sent by markItUp in preview.php with PHP?

// preview.php
<body>
<!-- content -->
</body>
Kitchenmaid answered 4/6, 2010 at 20:12 Comment(0)
B
7

You only need to set the previewParserPath and optionally the previewParserVar.

If you use this:

previewParserPath: '~/preview.php'

then markitup will look for a preview.php script to run in the same directory as the markitup jquery script--that's what the ~ character means.

If instead you set the preview path to something like this:

previewParserPath: '/preview.php'

then it will be relative to your web server root directory, as usual.

The implementation of the script it up to you; this is perhaps the most basic example:

echo htmlentities($_POST['data']);

The "data" there corresponds to the value of the previewParserVar setting; the default is "data".

In your app, you're probably going to want to do something useful with $_POST['data'] before you display it.

Brigadier answered 19/7, 2010 at 3:2 Comment(1)
I can't seem to get this to work, it complains "data" doesn't existShemikashemite

© 2022 - 2024 — McMap. All rights reserved.