Jump to content

PageTree as a markup module


owzim
 Share

Recommended Posts

AFAIK it's not a standalone right now, is it? Would be cool to have it as a markup module so that other modules could use it as well, the core would use it this way then too.

It should be definable what the root page of the tree is, so that it can be used very flexibly.

whaddayathink?

  • Like 1
Link to comment
Share on other sites

Every module is sort of standalone more or less. But I don't see the PageTree being very useful for front-end as it's built for the backend usage. It's geared a lot towards PW admin usage and not meant as a tree like other plugins out there jQueryJSTree.

Though as with most in PW it's fairly easy get a admin page tree working in your templates. After all the backend also is just a website. PageTree need the css, js and a js config to work. So it would work like this but on only show pages when logged in of course. Admin processes aren't accessible for not logged in users and PageTree uses ajax.

<?php

/**
 * Page template
 *
 */

// load page list module
$tree = $modules->ProcessPageList;
$tree->id = 1001;
$output = $tree->execute();

include("./head.inc");

// output the container markup, the rest does the js
echo $ouput;

And head.inc would need this to autoload assets and write the config js.

<script type="text/javascript">
    <?php
    $jsConfig = $config->js();
    $jsConfig['debug'] = $config->debug;
    $jsConfig['urls'] = array(
        'root' => $config->urls->root
        );
    ?>

    var config = <?php echo json_encode($jsConfig); ?>;
</script>

<?php foreach($config->styles->unique() as $file) echo "\n\t<link type='text/css' href='$file' rel='stylesheet' />"; ?>

<?php foreach($config->scripts->unique() as $file) echo "\n\t<script type='text/javascript' src='$file'></script>"; ?>

Edited for simpler version.

  • Like 1
Link to comment
Share on other sites

Just read again, and what you say is already like this. ProcessPageList is a module used by other like InputfieldPageListSelect. You could also used it in your module. But as you see even in other places it just works even if never was intentional to be used on front-end.


Parent can be set also using $config->js

Edit: Corrected my example above, as the $config->js(...) part isn't needed to configure. That's what the module does, I just had some order wrong. First call execute, then output the $config->js.

Or like kongondo demonstrated for in modules.

  • Like 2
Link to comment
Share on other sites

Thanks guys, ProcessPageList is exactly what I was looking/asking for. I didn't find it in core/module/markup so I was just looking in the wrong place. And I could not find it being used in the admin theme, so I thought it was somehow baked into the admin theme itself.

And Soma, I meant in the back end only of course. In the front end it would not make much sense, agreed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...