Jump to content
Robin S

Unordered List to Pages: action for Admin Actions

Recommended Posts

Creating a support topic for this action now that the new actions-as-modules feature has been added to Admin Actions.

Unordered List to Pages

An action for the Admin Actions module for ProcessWire CMS/CMF. Creates a structure of new pages from an unordered list entered into a CKEditor field. The nesting of further unordered lists within the list will determine the nesting of the created pages. Created pages get a default template that you select, and you can override this default template per list item by specifying a template name between [[ ]] delimiters.

This action can be useful to quickly create a page structure; especially so if you are rebuilding an existing non-ProcessWire site that has a Sitemap page that you can copy and paste from.

Usage

Install the Unordered List to Pages module.

Visit the Admin Actions config screen and enable the "Unordered List to Pages" action for the roles who are allowed to use it.

Navigate to Admin Actions > Unordered List to Pages and fill out the config fields:

Source

Enter/paste an unordered list in the Source field. There is a "cheatsheet" field above that explains the syntax you can use to set some template options for each list item.

If you want to override the default template for an item you can specify a template name after the page title between double square brackets. If the template doesn't already exist it will be created. Example: Page title [[staff_members]]

You can also specify one or more allowed child templates for a template like so: [[staff_members > manager tech_support]]This would create the page using the staff_members template, and set the allowed child templates of staff_members to manager and tech_support.

Alternatively you can specify one or more allowed parent templates for a template like so: [[manager < staff_members]] This would create the page using the manager template, and set the allowed parent templates of manager to staff_members.

Parent page

Select a parent page that the new pages will be created under.

Default template

Select the default template to use for the new pages.

Screenshots

Action config:

2018-09-28_204032

Result:

2018-09-28_204647

 

https://github.com/Toutouwai/AdminActionsUnorderedListToPages
https://modules.processwire.com/modules/admin-actions-unordered-list-to-pages/

  • Like 9

Share this post


Link to post
Share on other sites

Awesome work Robin - I can see this being my goto approach for quickly getting new site structures up and running! 

  • Like 2

Share this post


Link to post
Share on other sites

v0.1.3 released, with some new features thanks to a request from Adrian.

Any override templates specified in the list items will be created if they don't already exist. You can also set allowed parent templates or allowed child templates for a template within a list item. See the readme or the "cheatsheet" field for the syntax.

  • Like 3

Share this post


Link to post
Share on other sites

Just came here to say that this stuff rocks, @Robin S and @adrian! And looks so awesome in the new admin theme. I know it's nothing really special (for a person spoiled by using PW for a long time), just an import with a UI... But it feels like magic and even cheating))

The new way to add actions to Admin Actions module - a super feature - just a byproduct of this...??!! 😍

  • Like 2

Share this post


Link to post
Share on other sites

Good day, @Robin S!

Starting a new site. Creating structure with this module is really a breeze! Thanks!

I have spotted a minor inconvenience when preparing a list in a test editor and pasting it into the Source inputfield. The text editor (or is the inputfield itself?) is adding <p> tags around the <li> contents. And this leads to creating 0 pages. Would be awesome to clear all markup but the ul>li before processing.

  • Like 2

Share this post


Link to post
Share on other sites

Sadly, this doesn't work quite as expected here...

The first time I used it, every page was created in root.

The second time child and grand-child pages were created correctly, but there's something odd with the page-titles it generated for every parent page:

ul-to-pages.PNG.5fc86f3fe0d8b5ade25a5e86de9d5a6c.PNG

PW 3.0.125

  • Like 1

Share this post


Link to post
Share on other sites

@dragan, my previous commit to v0.1.4 contained a silly mistake that didn't account for nested lists. Should be fixed now in v0.1.5.

  • Like 1

Share this post


Link to post
Share on other sites

Sorry to spoil the party... 😐

Well, I'm not sure what this is all about, but right after creating the set of pages mentioned above, I went ahead and created another set.

This time, the uppermost ul parent was not created: instead I got only the direct child list pages (with correct child pages).

I checked that there were no pagename collisions or similar: there were no pages with the same page name as the one I defined as the main ul page-title.

I am using a multilanguage setup (although - only the title is textmultilang)... could this have to do with such inconsistencies?

I also made sure there was no accidental p tag in-between. The first thing I did when CKE loaded, is click on the list-icon, and then only used the indent/outdent buttons from CKE, to avoid such pitfalls.

I'll do some more tests and see if I can find a pattern here.

Share this post


Link to post
Share on other sites

@dragan, everything seems to be working normally for me. If you can paste some CKE source code from a list that is causing you problems I'll investigate.

Share this post


Link to post
Share on other sites

@dragan, I just pushed an update to the repo (no version number change) that adds the "Source" button to the CKEditor field to make it easier to check/report any issues with source code.

  • Like 1

Share this post


Link to post
Share on other sites

@Robin S Thanks!

I made two tests - everything works just fine now (didn't test yet with specifying templates using [[abc]], but no doubt that works as well)


 

Spoiler

<!-- 1st test -->

<ul>
    <li>Cities
    <ul>
        <li>Zürich</li>
        <li>Mumbai</li>
        <li>Berlin</li>
    </ul>
    </li>
    <li>Cars
    <ul>
        <li>Audi</li>
        <li>BMW</li>
        <li>Porsche</li>
    </ul>
    </li>
    <li>Colors
    <ul>
        <li>Red
        <ul>
            <li>Dark Red</li>
            <li>Light Red</li>
            <li>Ruby</li>
        </ul>
        </li>
        <li>Blue
        <ul>
            <li>Azure</li>
            <li>Sky Blue</li>
            <li>Deep Blue</li>
        </ul>
        </li>
        <li>Green</li>
    </ul>
    </li>
</ul>


<!-- 2nd test -->

<ul>
    <li>Countries
    <ul>
        <li>Switzerland
        <ul>
            <li>Cities
            <ul>
                <li>Bern</li>
                <li>Basel</li>
                <li>Zürich</li>
                <li>Genève</li>
            </ul>
            </li>
            <li>Lakes
            <ul>
                <li>Zürisee</li>
                <li>Lac Léman</li>
                <li>Murtensee</li>
            </ul>
            </li>
        </ul>
        </li>
        <li>Croatia
        <ul>
            <li>Places
            <ul>
                <li>Split</li>
                <li>Dubrovnik
                <ul>
                    <li>Things to See
                    <ul>
                        <li>Old Town</li>
                        <li>Church</li>
                    </ul>
                    </li>
                    <li>Where to Eat
                    <ul>
                        <li>Restaurant A</li>
                        <li>Restaurant B</li>
                        <li>Konoba C</li>
                    </ul>
                    </li>
                    <li>How to Get There
                    <ul>
                        <li>By Air
                        <ul>
                            <li>From Germany</li>
                            <li>From UK</li>
                            <li>From USA</li>
                            <li>From Australia</li>
                        </ul>
                        </li>
                        <li>By Car</li>
                        <li>By Bus</li>
                    </ul>
                    </li>
                </ul>
                </li>
            </ul>
            </li>
        </ul>
        </li>
    </ul>
    </li>
</ul>

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...