Recommended Posts

kixe    809

Find attached the first Alpha Version of the Module ProcessSetupPageName with Multilanguage Support. I tested it under various circumstances and it is doing fine with one exception: Until now it doesn't work together with 'Page Name Extended' (since PW 3.0.12) which allows UTF8 Page Names. Module requires PHP >= 5.4.x
Download from here:
EDIT: Removed link, download last version from here: https://github.com/kixe/ProcessSetupPageName/archive/master.zip

Would be nice if you could test it and give a feedback to me. Thanks in advance.

Edited by kixe
Due to some updates, I replaced the download link.
  • Like 3

Share this post


Link to post
Share on other sites
Filkaboy    2

There the error with the new file.

Error: Cannot access self:: when no class scope is active (line 70 of ../site/assets/cache/FileCompiler/site/modules/ProcessSetupPageName-master/ProcessSetupPageName.module)

For use it I just remove the self::$notes and replace by ''.

Share this post


Link to post
Share on other sites
kixe    809

@Filkaboy
Which PHP Version do you use? Both Errors you mentioned looking like PHP = 5.3.x Could you make an update of your PHP Version and try again? Thanks.

Fatal error: Using $this when not in object context in /site/modules/ProcessSetupPageName-master/ProcessSetupPageName.module on line 68

Error: Cannot access self:: when no class scope is active (line 70 of ../site/assets/cache/FileCompiler/site/modules/ProcessSetupPageName-master/ProcessSetupPageName.module)

Share this post


Link to post
Share on other sites
Filkaboy    2

@Filkaboy

Which PHP Version do you use? Both Errors you mentioned looking like PHP = 5.3.x Could you make an update of your PHP Version and try again? Thanks.

Yes exactly the problem... my previews version of php 5.3 and now with 5.5 all work fine.

Thank you

  • Like 1

Share this post


Link to post
Share on other sites
tpr    2,224

Great module but there's one thing that prevents me form using it, maybe this could be added in the future:

When adding a page and in the middle of the process you decide not to add a new page (skipping the Publish button and navigate away), then an empty page will be created. I think this coul be solved by adding a "Cancel" button next to the existing buttons ("Publish", "Save and....", "Cancel"). But perhaps there is an easier fix.

Don't get me wrong - I can delete the pages of course but I would use this module to make it easier for clients to add new pages, especially where the page name is actually irrelevant.

As a bonus feature request I would love to see message like these appear only for superusers - these may be too much for a regular client:

"SetupPageName expects value in field 'title' to autogenerate Pagename"

  • Like 1

Share this post


Link to post
Share on other sites
bernhard    1,323

Ryan solved this in pagetable as that pages created but not published are deleted automatically each day by a kind of lazycron. On mobile and no details for that... Just throwing in an idea

  • Like 1

Share this post


Link to post
Share on other sites
kixe    809

When adding a page and in the middle of the process you decide not to add a new page (skipping the Publish button and navigate away), then an empty page will be created. I think this coul be solved by adding a "Cancel" button next to the existing buttons ("Publish", "Save and....", "Cancel"). But perhaps there is an easier fix.

In fact the page is already created in the 'middle of the process' and it has to be created to pull the page name from other page fields. If you don't like this. Create a cronjob like bernhard mentioned. Example:

$wire->addHook('LazyCron::everyDay', function() {
    // trash untitled pages
    $delay = time()-60;
    $untitleds = wire('pages')->find("created<$delay,name^=untitled,include=all");
    foreach ($untitleds as $untitled) $untitled->trash(); // to delete permanently use $untitled->delete() instead
});
Don't get me wrong - I can delete the pages of course but I would use this module to make it easier for clients to add new pages, especially where the page name is actually irrelevant.

In this case you don't need this module. Use built in 'Name Format Children' in parent template settings and create the name frome date. It is also possible in my module to create the name from any autogenerated page property like 'created' or 'id'. Read the note in 'Name Format Children' field if module is installed.

As a bonus feature request I would love to see message like these appear only for superusers - these may be too much for a regular client:

"SetupPageName expects value in field 'title' to autogenerate Pagename"

This message is needed. How could the page editor know from where the values are pulled to generate the pagename? I don't want to change this.

  • Like 2

Share this post


Link to post
Share on other sites
tpr    2,224

Thanks, I will try a combination of fields then & try lazycron.

This message is needed. How could the page editor know from where the values are pulled to generate the pagename? I don't want to change this.

Sometimes the editors shouldn't care about the page name, for example when pages are created to hold content for content blocks. For example awards pages that won't have its own page at all.

  • Like 1

Share this post


Link to post
Share on other sites
kixe    809

As I said use built in options in this case. Read more here: https://processwire.com/api/modules/process-template/

To create contentblocks you can also use Repeaters (single template). Or better ProFields RepeaterMatrix (multiple templates). Repeaters are stored as pages too but very hidden and you don't need to care about naming.

Share this post


Link to post
Share on other sites
Krlos    17

Hi, I was trying this module, and I get this error:

Error: Uncaught Error: Call to a member function getDefault() on null in /Users/krlos/Documents/Sitios/processpdf/site/modules/ProcessSetupPageName/ProcessSetupPageName.module:99

Processwire: 2.7.2

PHP: 7.0.0

Share this post


Link to post
Share on other sites
Karl_T    35
On 2016/7/11 at 10:51 AM, Krlos said:

Hi, I was trying this module, and I get this error:


Error: Uncaught Error: Call to a member function getDefault() on null in /Users/krlos/Documents/Sitios/processpdf/site/modules/ProcessSetupPageName/ProcessSetupPageName.module:99

Processwire: 2.7.2

PHP: 7.0.0

I also get this error and found that this is due to the lack of  a core module called "Languages Support". The error is gone after install the module.

I suggest to add "Languages Support" to the dependency of this module.

Share this post


Link to post
Share on other sites
bee8bit    4

Hi,

this module throws an error when I create a new page.

Call to a member function getLanguageValue() on a non-object (Zeile 121 in /var/www/_html_default/processwire-playground/site/modules/ProcessSetupPageName/ProcessSetupPageName.module)


My name format for children is "date(Y/m/d) title", LanguageSupport is installed but the title field has the type PageName, not PageNameLanguage.

In this case, $page->title is a plain string, so this seems to work for me:

        // case 2: title default
        else if ($format == 'title') {
            if(is_object($page->title) && strlen($page->title->getLanguageValue($languageID))) {
                $pageName .= '-'.$page->title->getLanguageValue($languageID);
            } else {
                $pageName .= '-'.$page->title;
            }
        }

Further investigation might be necessary: Can $page->title->getLanguageValue(...) be an empty string?

Share this post


Link to post
Share on other sites
wolke    0

Hi,

it seems the module throws errors, when used together with Version Control. Pages which have version control enabled generate this error message.

I am not very good at php, so I cant investigate this further, but I would like to use this module. ATM I cant run the site without version control.

Uncaught Error: Call to a member function get() on null in /Applications/MAMP/htdocs/wire/core/Pages.php:321
Stack trace:
#0 /Applications/MAMP/htdocs/wire/core/WireArray.php(1933): ProcessWire\Pages->get('setModuleConfig...')
#1 /Applications/MAMP/htdocs/wire/core/WireArray.php(2149): ProcessWire\WireArray->implode('ProcessVersionC...', 'setModuleConfig...', Array)
#2 [internal function]: ProcessWire\WireArray->___callUnknown('setModuleConfig...', Array)
#3 /Applications/MAMP/htdocs/wire/core/Wire.php(374): call_user_func_array(Array, Array)
#4 /Applications/MAMP/htdocs/wire/core/WireHooks.php(549): ProcessWire\Wire->_callMethod('___callUnknown', Array)
#5 /Applications/MAMP/htdocs/wire/core/Wire.php(399): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Modules), 'callUnknown', Array)
#6 /Applications/MAMP/htdocs/wire/core/Wire.php(402): ProcessWire\Wire->__call('callUnknown', Array)
#7 /Applications/MAMP/htdocs/site/mo (Zeile 321 in /Applications/MAMP/htdocs/bluevr/wire/core/Pages.php) 

PW: 3.0.39

Share this post


Link to post
Share on other sites
kixe    809

@Krlos @Karl_T

On 11.7.2016 at 4:51 AM, Krlos said:

Hi, I was trying this module, and I get this error:


Error: Uncaught Error: Call to a member function getDefault() on null in /Users/krlos/Documents/Sitios/processpdf/site/modules/ProcessSetupPageName/ProcessSetupPageName.module:99

 

I fixed the single/ multilanguage issue. Sorry for the delay ...
Please update to 2.0.1 and try out.

  • Like 1

Share this post


Link to post
Share on other sites
PWaddict    88

How can I display on the backend the pages created with this module as titles instead of names?

For example I'm currently see the pages as: test-30-jan-2017. How can I see them as: Test 30 Jan 2017?

Sorry that was my mistake.

Share this post


Link to post
Share on other sites
kixe    809
On 13.2.2017 at 1:02 PM, PWaddict said:

@kixe Are you planning to make the module to update the page name when the fields that used to generate the name have been edited?

@PWaddict Thanks for the input. I made the module configurable with the option you mentioned. Furthermore I did some repairings for some special cases. Seems to work. Please try Version 2.0.2

  • Like 2

Share this post


Link to post
Share on other sites
PWaddict    88
8 hours ago, kixe said:

@PWaddict Thanks for the input. I made the module configurable with the option you mentioned. Furthermore I did some repairings for some special cases. Seems to work. Please try Version 2.0.2

I just tried it and unfortunately it doesn't work at all. I tried with both checked and unchecked the option just in case that was the problem.

Share this post


Link to post
Share on other sites
Robin S    2,529
9 hours ago, kixe said:

I made the module configurable with the option you mentioned.

Perhaps there should be some warning about this option in the readme and/or module config page, as it has the potential to inadvertently break links if the Page Path History module is not installed.

  • Like 1

Share this post


Link to post
Share on other sites
kixe    809
4 hours ago, PWaddict said:

I just tried it and unfortunately it doesn't work at all. I tried with both checked and unchecked the option just in case that was the problem.

I am sorry about that. Did you get any Errors? Exceptions? Please let me know. I tested the module in 2 different environments. It worked there without problems.

@Robin S

Thanks for the hint. I added a note to the config field and the readme.

  • Like 1

Share this post


Link to post
Share on other sites
PWaddict    88
1 hour ago, kixe said:

I am sorry about that. Did you get any Errors? Exceptions? Please let me know. I tested the module in 2 different environments. It worked there without problems.

There are no errors. It's just doesn't update the page name. I'm on localhost with php 7 and ProcessWire 3.0.52.

Share this post


Link to post
Share on other sites
kixe    809

@PWaddict

I missed to add the hook which update pagenames even if language support isn't enabled. I fixed this in Version 2.0.3
If you use the module in single language mode this might have been the cause. Thanks for your help.

  • Like 2

Share this post


Link to post
Share on other sites
PWaddict    88
52 minutes ago, kixe said:

@PWaddict

I missed to add the hook which update pagenames even if language support isn't enabled. I fixed this in Version 2.0.3
If you use the module in single language mode this might have been the cause. Thanks for your help.

Yep that was the problem. Now it's working perfect. Thank you very much.

  • Like 1

Share this post


Link to post
Share on other sites
PWaddict    88

@kixe I'm using a multi-language datetime field on the name format for children and it doesn't work properly. I'm using this format: %b %d, %Y and it can't update the page name with the format %b. It seems that it can only update the numeric formats.

Instead of getting this page name:
jan-22-2018

I'm getting this:
b-22-2018

Can you please fix it?

Share this post


Link to post
Share on other sites
kixe    809

The module uses php function date() and NOT strftime(). To get what you expect use the following format string: 'date(M-d-Y)'.

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By antoiba86
      I am a bit confused, because I don't know how to solve this problem.
      When I install the module Languages Support - Page Names, my web falls apart.
      I have all the necessary modules installed as Language support for example.
      This is the error I get in the admin panel.
      Warning: Invalid argument supplied for foreach() in /hosting/www/antoibaprogramming.com/public/wire/modules/LanguageSupport/LanguageSupportPageNames.module on line 107 Warning: Invalid argument supplied for foreach() in /hosting/www/antoibaprogramming.com/public/wire/modules/LanguageSupport/LanguageSupportPageNames.module on line 198 Warning: Invalid argument supplied for foreach() in /hosting/www/antoibaprogramming.com/public/wire/modules/LanguageSupport/LanguageSupportPageNames.module on line 1011 Warning: Invalid argument supplied for foreach() in /hosting/www/antoibaprogramming.com/public/wire/modules/LanguageSupport/LanguageSupportPageNames.module on line 1011 Warning: Invalid argument supplied for foreach() in /hosting/www/antoibaprogramming.com/public/wire/modules/LanguageSupport/LanguageSupportPageNames.module on line 1041
      And this in the front-end.
      Warning: Invalid argument supplied for foreach() in /hosting/www/antoibaprogramming.com/public/wire/modules/LanguageSupport/LanguageSupportPageNames.module on line 107
      Fatal error: Call to a member function get() on null in /hosting/www/antoibaprogramming.com/public/wire/modules/LanguageSupport/LanguageSupportPageNames.module on line 605 Fatal error: Call to a member function get() on null in /hosting/www/antoibaprogramming.com/public/wire/modules/LanguageSupport/LanguageSupportPageNames.module on line 605
    • By EyeDentify
      Simple example for loading template specific CSS file.
      This example asumes that you have your CSS file in a directory relative to template root.
      Like:
      templates/css/my_template_specific.css
      Also i use in the template a simple text field to hold the name of the CSS file i want to load.
      I call this field 'css_file'
      Use what you feel comfortable with.
      So in your header section of the DOM notice the "page specific CSS" part?
      Thats were the magic happens. What happens is that we check to see if the file exists in the CSS dir relative to template root.
      And if it does we load it. Simple and effective.
      I load all other CSS that is used all over the site in global_styles.css first.
      And make sure you load template specific last, because then you can easily override CSS in global.
       
      DOM header example:
      <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title><?PHP echo($page->title); ?></title> <!-- main CSS --> <link rel="stylesheet" href="<?PHP echo($config->urls->templates); ?>css/global_styles.css"> <!-- page specific CSS --> <?PHP /* Use relative path in file_exists() */ if(file_exists('css/' . $page->css_file)) { echo("<link rel=\"stylesheet\" href=\"{$config->urls->templates}css/{$page->css_file}\">"); } ?> </head> <body> Thats my way of doing it. I am sure there is plenty of more ways to do it. This is for the newbies or anyone that wants more options.
      Good luck with your CSS out there in Cyberspace.
      Cheers from EyeDentify
    • By kongondo
      The Module Blog for ProcessWire replicates and extends the popular Blog Profile.
      Blog is now in version 2.
      Please read the README in the Github link below in its entirety before using this module 
      Blog Documentation is here (Work in Progress!)
      See this post for new features in version 2 or the readme in GitHub.
      To upgrade from version 1, see these instructions.
      ##################################################
      Most of the text below refers to Blog version 1 (left here for posterity). 
       
      Blog version 1 consists of two modules:
      ProcessBlog: Manage Blog in the backend/Admin.
      MarkupBlog: Display Blog in the frontend.
      Being a module, Blog can be installed in both fresh and existing sites. Note, however, that presently, ProcessBlog is not compatible with existing installs of the Blog Profile. This is because of various structural and naming differences in respect of Fields, Templates, Template Files and Pages. If there is demand for such compatibility, I will code a separate version for managing Blog Profile installs.
      In order to use the 'Recent Tweets Widget', you will need to separately install and setup the module 'MarkupTwitterFeed'.
      Please read the README in the Github link below in its entirety before using this module (especially the bit about the Pages, etc. created by the module). 
      I'll appreciate Beta testers, thanks! Stable release works fine.
      Download
      Modules Directory: http://modules.processwire.com/modules/process-blog/
      Github: https://github.com/kongondo/Blog
      You can also install from right within your ProcessWire install.
      Screenshots (Blog version 1)

      Video Demos
      ProcessBlog
      MarkupBlog
      Credits
      Ryan Cramer
      The Alpha Testers and 'Critics' 
      License
      GPL2
    • By bernhard
      hi everybody,
      this is a preview of a module that i'm working on for quite a long time. I needed it for an intranet office management application that i'm still working on. It makes it very easy to create very customized Datatables using the awesome jquery datatables plugin (www.datatables.net)
       
      EARLY ALPHA release!
      It's very likely that there will lots of changes to this module that may cause breaking your implementations.
       
      Module source
      sorry, removed as it changes too frequently; closed alpha - contact me if you think you can contribute
       
       
      Remarks:
      The module is intended to be used on the backend. Loading styles is at the moment only done via adding files to the $config->styles/scripts arrays. Also the communicaton to javascript is done via the $config->js() method that is built into the admin and would have to be implemented manually on frontend use. But it would not be difficult of course
      Installation:
      Nothing special here, just download + install
       
      edit: removed some parts, because i made a complete rewrite of the module! (see last posting in the thread)
       
      Customization example:
      in the screencast you see an example that i'm using in a process module. i put the table inside an InputfieldMarkup just to have the same look&feel all around the admin. you see that you could also use this module to create tables quickly and easily using @kongondo s runtime markup module.
      complete PHP code:
      $this->headline('Kundenliste'); $form = $modules->get('InputfieldForm'); // init datatables module $dt2 = $modules->get('RockDataTables2'); // setup columns // name $col = new dtCol(); $col->name = 'name'; $col->title = 'Name'; $col->data = function($page) { return $page->title; }; $dt2->cols->add($col); // type $col = new dtCol(); $col->name = 'type'; $col->data = function($page) { return $page->rockcontact_type->title; }; $dt2->cols->add($col); // modified $col = new dtCol(); $col->name = 'modified'; $col->data = function($page) { $obj = new stdClass(); $obj->timestamp = $page->modified; $obj->display = date('d.m.Y', $page->modified); return $obj; }; $dt2->cols->add($col); // setup table $dt2->id = 'dt_kundenliste'; $dt2->js('/site/modules/ProcessRockProjects/dt_kundenliste.js'); $f = $modules->get('InputfieldMarkup'); $f->value = $dt2->render(); $form->add($f); // ################################## // ajax request -> return data // non-ajax -> render form + table // ################################## if($config->ajax) { echo $dt2->getJSON($pages->find('template=rockcontact, sort=random, limit=10000')); die(); } else $out .= $form->render(); return $out; what is interesting here is this part:
      // modified $col = new dtCol(); $col->name = 'modified'; $col->data = function($page) { $obj = new stdClass(); $obj->timestamp = $page->modified; $obj->display = date('d.m.Y', $page->modified); return $obj; }; $dt2->cols->add($col); datatables support orthogonal data (https://datatables.net/extensions/buttons/examples/html5/outputFormat-orthogonal.html). a date column is a good example, because you need to DISPLAY a formatted date (like 10.02.2017) but you need to be able to SORT this column by a different value (timestamp). its very easy to accomplish this by providing both values in your json. Btw: You could also just transfer the timestamp and do the formatting on the client-side via javascript. Next Example will show ho this would work. Both cases can be necessary, it's just an example here.
      [...] removed
      Why i created this module:
      of course i know @Soma s module but i needed a lot more features and the newer datatables version. also i like to define all the columns as objects and have everything on one place. lister & markupadmindatatable: nice for basic tables but lacks of features to modify the appearance of the cell values (like rendering icons, background colors and so on) datatables provides a great frontend API for filtering, showing/hiding columns, getting data, modifying it... it also plays well together with frontend charts like google chart api in this case:
       
      todo / roadmap:
      all kinds of column filters (like seen in the example above that shows an older and bloated version of this module) support for ajax filters and pagination (currently all filtering and sorting is done on the client side. i tried it with up to 50.000 rows and got reasonable results. initial loading took around 10sec. but of course this heavily depends on the complexity of your table and your data.  
       
       
    • By Robin S
      PageListTrash
      Allows non-superusers to trash pages directly from Page List (if they have page-delete permission for that page).
      Not much to say really - the module adds a "Trash" option to the extra actions for pages in Page List. It looks and works just like the Trash action available to superusers.

      https://github.com/Toutouwai/PageListTrash/
       
      Up to you whether you think non-superusers should be trusted with simpler trashing. For most cases I like the default behaviour where editors have to jump through some more hoops - I want them to think carefully about what they are doing. But if an editor needs to trash several pages then this module might reduce frustration.
      @tpr, by now you can probably predict what I'm going to say...
      ...something to merge into AdminOnSteroids?