Jump to content

Unordered List to Pages: action for Admin Actions


Robin S
 Share

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
Link to comment
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
Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
Share on other sites

  • 3 months later...

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
Link to comment
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
Link to comment
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.

Link to comment
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
Link to comment
Share on other sites

  • 11 months later...

I just got a weird error with this module and I'm a bit stumped...

After entering a list, the following error occurs, and no pages are being created:

admin-actions-lists-to-pages.thumb.PNG.e6cb967ce58485c3b73541bf4decfe49.PNG

 

CKE source code view:

admin-actions-lists-to-pages-2.PNG.91ee099a787eed50dc240cffb661dbef.PNG

ProcessWire: 3.0.149
PHP: 7.3.13
Webserver: Apache/2.4.35 (Win64) OpenSSL/1.1.1d 
MySQL: 5.7.24

I've been using this lovely module on-and-off for a while now, but never saw such an error msg before...

Link to comment
Share on other sites

6 hours ago, dragan said:

I just got a weird error with this module

Thanks for the report. PHP 7.3 apparently makes some changes to the regex engine and so an update to the bundled Simple HTML Dom Parser was needed. Done now in v0.1.6 of this module.

  • Like 3
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...