Jump to content
kongondo

Menu Builder

Recommended Posts

The answer here below:

The menu-id can be found in the browser-url, e.g.: processwire/setup/menu-builder/edit/?id=1035 when you are editing your menu.

To render the menu

<?php

 //load the module
$menu = $modules->get('MarkupMenuBuilder');//Load the module. $menu is an example
//render by name, title or id
echo $menu->render(1035,array('default_title' => 1));  //render by ID   default title = 1 and you get ML-support
?>
 
In de Readme  you find echo $menu->render('1234');//render by ID but with brackets you get an error so, it should be echo $menu->render(1234);//render by ID
  • Like 1

Share this post


Link to post
Share on other sites

@hansv,

Welcome to PW and the forums. Apologies I have been a bit busy and was not able to respond quicker. Glad you found the answer and thanks for finding the typo in the Readme I'll correct it. By the way, note that you can also pass a menu $page or an array of menu items in addition to the ID 

Share this post


Link to post
Share on other sites

yeah, i've set it to 4 (just to make sure it's high enough), but the parent item is only marked current, when i include the children (include_children => 1).

but, with these settings the childpages are also included in the html of the menu, which i don't want.

here are my settings:

$menuOptions = array(
                    'current_class' => 'current',
                    'include_children' => 1,//show 'natural' MB non-native descendant items as part of navigation
                    'm_max_level' => 1,//how deep to fetch 'include_children'
                    'current_class_level' => 4,//how high up the ancestral tree to apply 'current_class'
             ); 

thanks!

@Torsten,

That's the current behaviour - only native menu builder child items & natural (tree) children associated via 'include_children' are affected by 'current_class_level'. I'll mull over extending the behaviour (via an API option) to include natural (tree) but non-associated children similar to the case you've described.

Share this post


Link to post
Share on other sites

Hi guys,

I have a  similar / the same problem as Torsten. But somehow, if I set "current_class_level" to 2, it doesn't seem to apply, for reasons I don't understand. My site structure looks something like this

Home

about

used stuff

products

Tv

Home Cinema

Speakers

Streaming solutions

etc.

 

If I navigate to products, the script automatically assigns the css-class "active" to the selected menu item, which changes the color of the menu item in the navbar. If I navigate to one of the children of "products" (TV,Home cinema etc.) though, my top menu item "products" loses its css class. 

I thought I could prevent "products" from losing its css- class when browsing children of "products" by increasing the value of 'current_class_level' to something greater than 1.

But if I do so, it doesn't change anything, my menu item "products" still loses its class when I navigate to one of its children.

I hope my description was understandable, and I hope even more that someone has a solution for my problem.

Best regards,

derelektrischemoench

Share this post


Link to post
Share on other sites

@derelektrischemoench,

Welcome to the forums. It works fine for me, both for 'included' (natural PW) children and native (MenuBuilder) children. Are you certain that your current class 'active' is not being applied as opposed to applied but overridden by another CSS class (e.g. 'last') via CSS Specificity/Cascade? Alternatively, can you confirm you are passing your $options properly to render() ?


@all....

I haven't forgotten pending requests/issues...I'm just currently swamped with other stuff. I hope to address concerns soon. Thanks for your patience.

Share this post


Link to post
Share on other sites

@derelektrischemoench,

Welcome to the forums. It works fine for me, both for 'included' (natural PW) children and native (MenuBuilder) children. Are you certain that your current class 'active' is not being applied as opposed to applied but overridden by another CSS class (e.g. 'last') via CSS Specificity/Cascade? Alternatively, can you confirm you are passing your $options properly to render() ?

@all....

I haven't forgotten pending requests/issues...I'm just currently swamped with other stuff. I hope to address concerns soon. Thanks for your patience.

Hi Kongondo,

so I reviewed my css (it's not that much so far), and  I didn't find the use of the class "active" or anything comparable that would mess this stuff up further down the cascade, but I guess that's not the problem here. If I inspect my code and select a child item from my menu, the script simply doesn't apply the class "active", meaning the output markup stays completely the same.

This is the code that generates my menu so far:

<?php 

         $options = array(

                'wrapper_list_type' => 'ul',//ul, ol, nav, div, etc.
                'list_type' => 'li',//li, a, span, etc.
                'menu_css_id' => 'nav',//a CSS ID for the menu
                'menu_css_class' => 'drop',//a CSS Class for the menu
                'submenu_css_class' => 'submenu',//CSS Class for sub-menus
                'has_children_class' => 'menu_child',//CSS Class for any menu item that has children
                'first_class'=>'menu_top',//CSS Class for the first item in 
                'last_class' => 'menu_bottom',
                'current_class' => 'active',
                'current_class_level' => 2,//how high up the ancestral tree to apply 'current_class'
                'default_title' => 0,//0=show saved titles;1=show actual/current titles
                'include_children' => 4,//show 'natural' MB non-native descendant items as part of navigation
                'm_max_level' => 2,//how deep to fetch 'include_children'
                
                );           

            $menu = $modules->get("MarkupMenuBuilder");
             //load the module
            echo $menu->render('nav', $options);

           

        ?>

so from my understanding the line 'current_class' => 'active' should assign the class "active" to the currently selected/active menu item, which would then enable me  to adress this class via css, correct?

Unfortunately this class assignment doesn't take place :(

Perhaps I got some of the code generating the menu wrong, I'm relatively new to programming and have yet to overcome sucking at it, so feel free to correct me   :-)

Thx so far

derelektrischemoench

//edit: Solved it myself. The problem was that I didn't set my "home" page as the parent of the menu tree, I assumed current_class_level somehow magically recognized the site tree and applied .active to parent items. Which, of course, it didn't.

Thx nevertheless, sry for wasting time by being stupid :D

Share this post


Link to post
Share on other sites

ProcessWire n00b here, be gentle!

Building my first ProcessWire site and one of the first problems I am running into is the menu system. Don't understand the logic in not having some kind of menu/nav builder in the Admin. Luckily I came across MenuBuilder!! So very simple to install and setup, thanks!

My site is based on BootStrap 3 and I am not finding enough "options" in the Menu Builder setup to get it working correctly. Hoping some one can point my in the right direction or a quick fix to the code could be done? Below is the correct code. I have hightlighted the pieces I can't figure out how to do with Menu Builder.

Edit: Apparently you can't highlight in the code block... Here's the bits in the top level menu item that has drop downs I need to add to the < a >:

  • class='dropdown-toggle'
  • data-toggle='dropdown'
  • <b class="caret"></b>

Any assistance is appreciated!

<ul class="nav navbar-nav navbar-right">
<li class='current'><a href='/'>Home</a></li>
<li class='dropdown'><a class='dropdown-toggle' href='/about/' data-toggle='dropdown' title='About'>About <b class="caret"></b></a>
<ul class='dropdown-menu'>
<li><a class='' href='/about/what/'  title='Child page example 1'>Child page example 1 </a></li>
<li><a class='' href='/about/background/'  title='Child page example 2'>Child page example 2 </a></li>
</ul>
</li>
<li><a class='' href='/site-map/'  title='Site Map'>Site Map </a></li>
</ul>

Share this post


Link to post
Share on other sites

Looks like I was able to figure out a slight code tweak. Not sure if this is something that should make it's way into the official code or not (or if it is too 'hacky' to be of use to everyone):

Replace (around line 349 in the MarkupMenuBuilder.module):

//if $iTag is empty, apply css id and classes to <a> instead
if(!$iTag) $out .= "\n\t<a{$itemCSSID} {$class}{$newtab} href='{$m->url}'>{$m->title}</a>";
else $out .= "\n\t<{$iTag}{$itemCSSID}{$class}>\n\t\t<a{$newtab} href='{$m->url}'>{$m->title}</a>";

With:

//Bootstrap A tag edits
if($m->isParent && $o->bootstrap) {
$itemHasChildrenLink = ' data-toggle="dropdown" class="dropdown-toggle"';
$itemHasChildCaret = ' <span class="caret"></span>';
}
else {
$itemHasChildrenLink = '';
$itemHasChildCaret = '';
}

//if $iTag is empty, apply css id and classes to <a> instead
if(!$iTag) $out .= "\n\t<a{$itemCSSID} {$class}{$newtab}{$itemHasChildrenLink} href='{$m->url}'>{$m->title}{$itemHasChildCaret}</a>";
else $out .= "\n\t<{$iTag}{$itemCSSID}{$class}>\n\t\t<a{$newtab}{$itemHasChildrenLink} href='{$m->url}'>{$m->title}{$itemHasChildCaret}</a>";

Then add @ line 977 to create a new option:

$this->set('bootstrap', isset($options['bootstrap_menu']) ? $options['bootstrap_menu'] : 0);
Where:
bootstrap  //Test for bootstrap style menus - 1 = Yes / 0 = No [default]

Share this post


Link to post
Share on other sites

Hi.

I get this error when saving menu items. The problem only arises when language support installed.

Error: Call to a member function getLanguageValue() on a non-object (line 1750 of /Users/vayu/Sites/processshop.dev/site/modules/ProcessMenuBuilder/ProcessMenuBuilder.module) 
This error message was shown because you are logged in as a Superuser. Error has been logged.

I have tested this on a clean install of Processwire version 2.6.1.

  • Like 1

Share this post


Link to post
Share on other sites

Hi.

I get this error when saving menu items. The problem only arises when language support installed.

Error: Call to a member function getLanguageValue() on a non-object (line 1750 of /Users/vayu/Sites/processshop.dev/site/modules/ProcessMenuBuilder/ProcessMenuBuilder.module) 
This error message was shown because you are logged in as a Superuser. Error has been logged.

I have tested this on a clean install of Processwire version 2.6.1.

I had already reported this issue on Github, where I posted a problem-solution that works. Hope it helps. https://github.com/kongondo/MenuBuilder/issues/22

David

  • Like 4

Share this post


Link to post
Share on other sites

If I was to put a static/hardcoded <li></li> into a Menu Builder menu, how would I best approach a solution? Is there a way to have no wrapper_list_type, or echo my additional <li></li> together with $out?

I guess my problem could be solved with Hanna Code, but the question still intrigue me.

Here's my current code, for reference. With two <ul>s that I am trying to merge into one.

<?php if($user->isSuperuser()) : ?>
<ul>
  <li><a href='<?php echo $page->editURL; ?>'><i class='fa fa-pencil'></i> <?php echo __('Rediger', '/site/templates/header.inc'); ?></a></li>
  <li><a href='<?php echo $config->urls->admin; ?>'><i class='fa fa-gears'></i> <?php echo __('Kontrollpanel', '/site/templates/header.inc'); ?></a></li>
</ul>
<?php 
$adminmenu = 'administrator-menu';
$options = array( 'wrapper_list_type' => 'ul', 'list_type' => 'li');
$menu = $modules->get('MarkupMenuBuilder');
$out = $menu->render($adminmenu, $options);
echo $out;
?>
<?php endif; ?>

Share this post


Link to post
Share on other sites

Hey @kongondo,

I love this module and I'm featuring it in a comparison to WordPress's menu builder in my screencast series, however I feel there could be some general UI/UX improvements that can really make it feel more "native" and simplify what I feel is option overload.  Please take this as constructive criticism.

Here are my thoughts:

  1. Perhaps remove the ability to create multiple menus.  It's a nice feature but it feels like overkill since sites typically don't have more than just a few menus.  (or disable this option by default and perhaps have it enabled in the module's settings for advanced used).  Perhaps add a standard "Add New" button instead that follows the typical Page creation process.
  2. For the same reasons above, remove batch actions to delete, unpublish, etc.  (or disable this option by default and perhaps have it enabled in the module's settings for advanced used).
  3. When going in to edit a menu, make the first tab be "Structure" which is selected by default.  This is typically the first action most people would want to take so it would feel more natural for it to be the first tab item. There should be 3 fieldsets/sections in this "Structure" tab:
    1. Add Page
    2. Add Custom Link
    3. Menu Items
  4. Perhaps simplify how you can add pages to your menu:
    1. Remove the existing 3 methods: Pages (both ASM and PageAutoComplete), Custom, Selector
      1. In regards to adding pages using Selectors, perhaps have this disabled by default, but an option that can be enabled in the modules settings.  It's an advanced feature but I'd imagine wouldn't be as commonly used and therefore feels a bit overwhelming.
    2. If possible, replace with a ProcessPageList (this is what goes inside the "Add Page" fieldset).  It feels like a more natural fieldtype since it uses the tree.
      1. since this would replace the ASM way of adding menu items, that means you can't change a CSS Class/ID until AFTER it's been added to the menu.  I think that's OK since right now you change CSS Classes/IDs both before and after adding the menu item, which I find a little confusing.
    3. If possible, upon clicking a page to add to your menu on the ProcessPageList, it should show an "add" action/button (native ProcessPageList action stuff), that when clicked, adds the page to the actual menu (some ajax/dom manipulation required here I think) instead of putting it in a "limbo" state like it is right now until a page is saved.
    4. As far as being able to add custom links, that should go under the "Add Custom Link" fieldset.  Perhaps also remove batch ability to add Custom Links and utilize general Inputfieldtext instead of a table structure.  Remove ability to set CSS Class and ID at this stage.
  5. Now for the "Menu Items" section:
    1. Right now, you're utilizing custom styling and javascript for the adding page items and creating the toggle boxes, however it should be possible to use make each added menu item act as an InputfieldFieldset.  When each item/fieldset is clicked, it should reveal the 5 editable fields (Title, URL, CSS ID, Class Class, New Window) and ability to delete.  Apply the nestedSortable JS to that list to make it have drag/drop capability with indenting.  A final result similar to this screenshot which I hacked together.
  6. "Main" tab should be renamed to "Settings".  Put as second tab.
  7. "Items Overview" tab: this could be removed (or disabled by default) since it's essentially just displaying the same menu in a table.  Feels repetitive.
  8. "Delete" tab should remain as is.

What do you think?

  • Like 2

Share this post


Link to post
Share on other sites

Hi,

thanks for the module, I think this is a great addition!

Is there a way to set default classes for the menu's li items and possible for the included a tags as well?

To keep nesting flat in the css, our stylesheet uses ".list-item" and ".list-item-link" classes.

And, would it be possible to set via the $options to not include the outermost "ul"? this would take care for instances like laban describes above (https://processwire.com/talk/topic/4451-menu-builder/page-6#entry97178) or my use case, where I'd like to add a "login / logout" nav item to the footer-menu - depending on the logged in state of the user this is either /login or /logout. I would add this in the template, not as an item via the menu builder, but it still needs to be enclosed in the "ul" wrap of the rendered menu.

Or would those two use cases be better taken care of if I used the JSON -> array() thing, just taking the infos provided by the menu builder and creating my own markup around it?

Anyways, great work, really looking forward to use this in a production site :-)

Share this post


Link to post
Share on other sites

WOW! Just to answer myself; all of the above can easily be covered. Just don't use the render(); method.

Step 1: fetch your menu data and store it in an array:

$footermenu_items_json =  $pages->get('name=footer-menu')->menu_items; // this is the menu page in menu builder, could also be fetched with the ID
$footermenu_items = json_decode($footermenu_items_json, true);

Step 2: use that array to build your custom markup:

if( count($footermenu_items) > 0 ){
  $out = '<ul class="nav-list">';
  foreach($footermenu_items as $item){
    $url = ($item['url']) ? $item['url'] : $pages->get($item['pages_id'])->url;
    $target = (1 == $item['newtab']) ? 'target="_blank"':'';
    $out .= '<li class="list-item"><a href="' . $url . '" class="list-item-link" ' . $target . '>' . $item['title'] . '</a></li>';
  }
  if( $user->isLoggedin() ){
    $out .= '<li class="list-item"><a href="' . $pages->get('name=login, template=login')->url . 'logout/' . '" class="list-item-link">Logout</a></li>';
  } else {
    $out .= '<li class="list-item"><a href="' . $pages->get('name=login, template=login')->url . '" class="list-item-link">Login</a></li>';
  }
  $out .= '</ul>';
  echo $out;
}

Just make sure to var_dump the array somewhere to get an idea of what info is stored in there for the nested levels, etc.

This is really neat. For me it's the best of both worlds - I can easily create and maintain menus in the backend, but can still fully control the output in the template. Thank you!!

cheers,
Tom

  • Like 4

Share this post


Link to post
Share on other sites

@all,

Again, this is just a quick holding post....I am still tied up and cannot presently address your issues. 

@jonathan...thanks for taking the time to review the UI of the module. I hope to respond to your thoughts/suggestions soon.

Thank you all for your patience... :)

Share this post


Link to post
Share on other sites

Hi! Thanks for the great module!

After deciding that its functionality was a bit too much for what I wanted to do right now, I tried to uninstall the module but it throws this error: 

Can't delete template 'menus' because it is used by 1 pages.

The Markup Module unisntalls just fine.

 I am using PW 2.6.1

Thanks for further assistance,

Share this post


Link to post
Share on other sites

Hi,

is there any progress with post 110?

I get the same error, when i using menubuiler with language support activated.  :( 

Share this post


Link to post
Share on other sites

Looks like I was able to figure out a slight code tweak. Not sure if this is something that should make it's way into the official code or not (or if it is too 'hacky' to be of use to everyone):

Replace (around line 349 in the MarkupMenuBuilder.module):

//if $iTag is empty, apply css id and classes to <a> instead
if(!$iTag) $out .= "\n\t<a{$itemCSSID} {$class}{$newtab} href='{$m->url}'>{$m->title}</a>";
else $out .= "\n\t<{$iTag}{$itemCSSID}{$class}>\n\t\t<a{$newtab} href='{$m->url}'>{$m->title}</a>";

With:

//Bootstrap A tag edits
if($m->isParent && $o->bootstrap) {
$itemHasChildrenLink = ' data-toggle="dropdown" class="dropdown-toggle"';
$itemHasChildCaret = ' <span class="caret"></span>';
}
else {
$itemHasChildrenLink = '';
$itemHasChildCaret = '';
}

//if $iTag is empty, apply css id and classes to <a> instead
if(!$iTag) $out .= "\n\t<a{$itemCSSID} {$class}{$newtab}{$itemHasChildrenLink} href='{$m->url}'>{$m->title}{$itemHasChildCaret}</a>";
else $out .= "\n\t<{$iTag}{$itemCSSID}{$class}>\n\t\t<a{$newtab}{$itemHasChildrenLink} href='{$m->url}'>{$m->title}{$itemHasChildCaret}</a>";

Then add @ line 977 to create a new option:

$this->set('bootstrap', isset($options['bootstrap_menu']) ? $options['bootstrap_menu'] : 0);
Where:
bootstrap  //Test for bootstrap style menus - 1 = Yes / 0 = No [default]

Great work! Hacky but great! I'm also new to PW but I'm loving it so far.

My solution for using MenuBuilder with Bootstrap 3 is kinda hacky as well. No need to change the module code here but it's definitely some sloppy coding, like don't-try-this-at-home-sloppy.

Configure the options like so:

$options = array(
           'wrapper_list_type'  => 'ul',
           'menu_css_class'     => 'nav navbar-nav',
           'submenu_css_class'  => 'dropdown-menu',
           'has_children_class' => 'dropdown',
);

And do the rest with jQuery: (the sloppy part)

$(document).ready(function () {
       $(".dropdown [href='#']:first-child").attr("data-toggle", "dropdown").addClass('dropdown-toggle');
});

I know the the dropdowns are selected with [href=#] (which is horrible). I did that because reasons. It works. And it took only 30 minutes to figure out. That proofs how awesome this module is!

Share this post


Link to post
Share on other sites

I had already reported this issue on Github, where I posted a problem-solution that works. Hope it helps. https://github.com/kongondo/MenuBuilder/issues/22

David

@David and other experiencing this issue. I have not been able to replicate the issue. Please see my comment on the issue at Github. Could someone please provide responses to the questions I have detailed there? Thanks.

Share this post


Link to post
Share on other sites

Hi all!

I am new to PW and I am using the module MenuBuilder just for creating the menu of my web site, but I have a problem when I swicth language from English to another; in fact when I switch to Italian language for example, the menu does not appear and sometimes an error appears ("Error: No menu items found"). I would like to ask if somebody knows how to create a multilanguage menu by means of Menu Builder and if yes, can show me how to do it.

Thanks in advance

Share this post


Link to post
Share on other sites

Hi @Mattia90,

Welcome to ProcessWire and the forums. Sorry about the problems you are encountering with MenuBuilder. I am the author of the module. To be honest, I know next to nothing about multilingual setups. I don't know how to add or remove a language or how to specify a default language nor about the various approaches to setting up a multilingual site :-). However, I have tested MenuBuilder with the default ProcessWire multilingual install and it works fine. Other guys have had issues with MenuBuilder after they'd removed a language. I have not been able to reproduce some of the issues. So, unless someone can give me a 'dummies' step-by-step instruction on how to reproduce their multilingual error/bug, I have no way of fixing the issues :(.

Share this post


Link to post
Share on other sites

Hi @kongondo!

Thank you for your reply. Now I explain in a detailed way what I did:

1) My idea was to create a web site both in English and in Italian and in order to do this, according to the official documentation of ProcessWire, I installed all the modules that you can find under the voice "Language" (Language Support) : in the admin page, Modules -> Core;

2) I have created a menu by means of admin page: Setup -> Menu Builder and here I created a menu with title "Menu_X" and then I built the menu by adding the pages that I wanted.

3) In order to have this web site in Italian and in English, in order to have the possibility to switch from one language to the other one, I added in each page this piece of code taken from the official documentation of ProcessWire:

$menu = $modules->get("MarkupMenuBuilder"); //load the module
 
$options = array(
         'wrapper_list_type' => 'ul',
         'list_type' => 'li',
         'menu_css_id' => '',
         'menu_css_class' => 'nav navbar-nav',
         'submenu_css_class' => 'hvr-bounce-to-bottom',
         'current_class' => 'active',
         'current_css_id' => '',
         'divider' => '»',// e.g. Home >> About Us >> Leadership
         //prepend home page at the as topmost item even if it isn't part of the breadcrumb
         'prepend_home' => 0,//=> 0=no;1=yes
         'default_title' => 0,//0=show saved titles;1=show actual/current titles
         'include_children' => 4,//show 'natural' MB non-native descendant items as part of navigation
         'b_max_level' => 1,//how deep to fetch 'include_children'
);
 
echo $menu->render('Menu_X', $options); //render the menu

This is a select that allows to switch from English to Italian and viceversa.

4) Now when I created the "Menu_X", there wasn't the possibility to specify the titles of the different menu items in both languages and also the different urls: in fact the menu works only in the default language (English); what it seems strange is that when I switch from English to Italian, this error appears: "Fatal error: Exception: No menu items found! Confirm that such a menu exists and that it has menu items."

In the worst case, what I expected is to have the same menu both in Italian and in English. I would like to have how to create a multilingual menu with the right urls by means of Menu Builder.

Thanks in advance.

Edited by kongondo
wrapped code in code block

Share this post


Link to post
Share on other sites

Hi @Mattia90

Apologies for the delay in getting back to you. I don't know about your setup there but MenuBuilder should work out of the box with a Multi-lingual site except for this one issue reported here include a possible fix which I am yet to implement. Does that fix help in your case? MenuBuilder will read and load the correct language of the user. No need to specify titles for each language when building the menu. 

What do you mean by: 

 This is a select that allows to switch from English to Italian and viceversa.

Is Menu_X the title of the menu you created?

Does your site work normally otherwise?, i.e. without MenuBuilder? Like I said, I have tested it with ProcessWire's site-languages and it works fine (with three languages). 

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 jploch
      Hey folks,
      for a module (a pagebuilder based on PageTable) I need to save some settings as JSON. The values are saved for each page table item (a pw page). It's working well, but I am looking for ways to improve the structure I have. As I'm not that experienced with JSON, maybe someone more experienced can take a look and tell me if my approach is good practice. 

      My goal is to make all the items accessible by page id, without looping over them (using objects instead of arrays):
      // access from template with pw page var $jsonObject->items->{$page}->cssClass; Her is an example of my JSON structure:
      { "items": { "3252": { "id": "3252", "cssClass": "pgrid-main", "breakpoints": { "base": { "css": { "grid-column-end": "auto", "grid-row-end": "auto", "grid-column-start": "auto", "grid-row-start": "auto", "align-self": "auto", "z-index": "auto", "padding-left": "60px", "padding-right": "60px", "padding-top": "60px", "padding-bottom": "60px", "background-color": "rgb(255, 255, 255)", "color": "rgb(0, 0, 0)" }, "size": "@media (min-width: 576px)", "name": "base" } } }, "3686": { "id": "3686", "cssClass": "test_global", "breakpoints": { "base": { "css": { "grid-column-end": "-1", "grid-row-end": "span 1", "grid-column-start": "1", "grid-row-start": "auto", "align-self": "auto", "z-index": "auto", "padding-left": "0px", "padding-right": "0px", "padding-top": "0px", "padding-bottom": "0px", "background-color": "rgba(0, 0, 0, 0)", "color": "rgb(0, 0, 0)" }, "size": "@media (min-width: 576px)", "name": "base" } } }, "3687": { "id": "3687", "cssClass": "block_editor-3687", "breakpoints": { "base": { "css": { "grid-column-end": "span 2", "grid-row-end": "span 1", "grid-column-start": "auto", "grid-row-start": "auto", "align-self": "auto", "z-index": "auto", "padding-left": "0px", "padding-right": "0px", "padding-top": "0px", "padding-bottom": "0px", "background-color": "rgba(0, 0, 0, 0)", "color": "rgb(0, 0, 0)" }, "size": "@media (min-width: 576px)", "name": "base" } } }, "3696": { "id": "3696", "cssClass": "block_editor-3696", "breakpoints": { "base": { "css": { "grid-column-end": "span 2", "grid-row-end": "span 1", "grid-column-start": "auto", "grid-row-start": "auto", "align-self": "auto", "z-index": "auto", "padding-left": "0px", "padding-right": "0px", "padding-top": "0px", "padding-bottom": "0px", "background-color": "rgba(0, 0, 0, 0)", "color": "rgb(0, 0, 0)" }, "size": "@media (min-width: 576px)", "name": "base" } } } }, "breakpointActive": "base", "breakpointActiveSize": "@media (min-width: 576px)" }  
    • By jploch
      Fieldtype Page Table Grid
      This is a sneak preview of a side project I've been working on for quite some time now. A lot of work and thought has gone into this, so I will most likely release this as a commercial module at some point in the near future. 

      As a designer (and developer) I get the appeal of a WYSIWYG editor. After playing around with some WYSIWYG page builder tools, I always felt something was wrong about them. So I decided to build my own PW version based on PageTable.

      Here is a small demo (using AdminThemeCanvas, but its working with other admin themes as well) :
      There is also a complete website that I built for a friend of mine using this module and some custom blocks.
      Concept
      This fieldtype shares a lot of features with PageTableExtended: it's also an extension of PageTable and renders the block templates in the backend and frontend (native PW templates and fields). You can also add your own css via module settings.
      The difference is, this fieldtype also gives you the ability to rearrange and resize elements in a visual way as well as enable inline editing for text, ckeditor and file fields. Similar (and promising) attempts have been made, but I wanted something based on native CSS grid instead of a CSS framework...so I built my own version. Most CSS frameworks are based on flexbox, which is great for layouting elements horizontally. With CSS grid, you can place elements horizontally and vertically, allowing for layouts that were not previously possible with CSS. Similar to webflow, this fieldtype uses javascript (in the backend) to let you manipulate CSS grid in a visual way to design fully responsive websites (or parts of them). It should still be possible to include a CSS framework if you like (just add the classes to your block markup and include the CSS via module settings).
      The CSS grid layout manipulations are saved in a single field as a JSON array and used to generate a dynamic stylesheet that you simply include in your main template (no inline styles). The styles are saved within the breakpoint you select and cascade down to smaller breakpoints. That means you can specify just the basic breakpoint and adjust other breakpoints if needed. The exception is the mobile breakpoint which will display everything in one column as a default (you can change the layout here too).
      The fieldtype also comes with an optional style panel to manipulate some additional CSS properties directly on the page. You can customize the panel or disable it completely from the module settings (and just use a CSS file that you include via module settings). The style panel is based on inputfields (nothing is saved to the database). This means that you just have to install the module and all fields are available to all blocks automatically (this can be customized). It also has the benefit that your installation is not flooded with fields; this module only installs one field.
      Don't want to give your customer all that power? Design features can be disabled for certain roles. The grid editor role can just edit the content and use the inline editing feature to edit content quickly. You can then also grant access individually to the style panel, resize or drag functionality.
      Features
      Blocks are just pages Blocks are defined by native PW templates and fields Manipulate CSS grid in a visual way to design fully responsive websites (or parts of them) Design features can be disabled for certain roles Inline editing of text, ckeditor and file fields The layout is 100% CSS grid (very small css file size) Simply drag and resize to manipulate grid items directly inside the backend Manipulate grid columns and rows directly on the page (use any number of columns you want) All style manipulations are saved as JSON and used to generate a dynamic stylesheet that you just include in your main template (no inline styles) Nested groups/grids (child pages of nested blocks are created under group parent) Global blocks work with page reference field (changes on one page, changes all blocks on all pages) Manual and auto placement of grid items Define custom icons for your blocks via native template settings (template -> advanced -> icon) Option to load lazysizes in the backend to enable lazy loading of assets with class lazyload Works with all default and ui-kit based admin themes If you have any questions or feedback, let me know.
    • By bernhard
      I built this module because I needed a versatile solution to replace tags and simple if-blocks in some E-Mails and PDF documents.
      If you only need to replace static tags (no if-conditions), then you can use default PW api and need no module:
      $str = "My favourite color is {color}."; $texttools = $sanitizer->getTextTools(); echo $texttools->populatePlaceholders($str, ['color' => 'red']); // output: My favourite color is red. Usage:
      See the two example Files in the folder /replacements

       
      Methods:
      replacementsTable()
      Renders an overview of all available replacements (see the example in the Module's config file:
       
      Create new Replacements:
      Simply copy the sample file and adopt to your needs.
       
      Download:
      https://gitlab.com/baumrock/RockReplacer
    • By bernhard
      DEPRECATED
      I'm using this module in several projects, but it will likely not see any updates in the future. I'm not happy with it and I'm looking for ways to develop better solutions. RockTabulator was my first try, but I'm also not 100% happy with that. The tabulator library is great, but my module implementation is not. I hope to get a good solution soon, but it will be a lot of work...
      ---
      Some of you might have followed the development of this module here: https://processwire.com/talk/topic/15524-previewdiscussion-rockdatatables/ . It is the successor of "RockDataTables" and requires RockFinder to get the data for the grid easily and efficiently. It uses the open source part of agGrid for grid rendering.
       
      WHY?
      ProcessWire is awesome for creating all kinds of custom backend applications, but where it is not so awesome in my opinion is when it comes to listing this data. Of course we have the built in page lister and we have ListerPro, but none of that solutions is capable of properly displaying large amounts of data, for example lists of revenues, aggregations, quick and easy sorts by the user, instant filter and those kind of features. RockGrid to the rescue 😉 
       
      Features/Highlights:
      100k+ rows Instant (client side) filter, search, sort (different sort based on data type, eg "lower/greater than" for numbers, "contains" for strings) extendable via plugins (available plugins at the moment: fullscreen, csv export, reload, batch-processing of data, column sum/statistics, row selection) all the agGrid features (cell renderers, cell styling, pagination, column grouping etc) vanilla javascript, backend and frontend support (though not all plugins are working on the frontend yet and I don't plan to support it as long as I don't need it myself)  
      Limitations:
      While there is an option to retrieve data via AJAX the actual processing of the grid (displaying, filtering, sorting) is done on the client side, meaning that you can get into troubles when handling really large datasets of several thousands of rows. agGrid should be one of the most performant grid options in the world (see the official example page with a 100k row example) and does a lot to prevent problems (such as virtual row rendering), but you should always have this limitation in mind as this is a major difference to the available lister options that do not have this limitation.
      Currently it only supports AdminThemeUikit and I don't plan to support any other admin theme.
       
      Download: https://gitlab.com/baumrock/FieldtypeRockGrid
      Installation: https://gitlab.com/baumrock/RockGrid/wikis/Installation
      Quikckstart: https://gitlab.com/baumrock/RockGrid/wikis/quickstart
      Further instructions: https://gitlab.com/baumrock/RockGrid/wikis/quickstart#further-instructions
      German Translation File: site--modules--fieldtyperockgrid--fieldtyperockgrid-module-php.json
      Changelog: https://gitlab.com/baumrock/FieldtypeRockGrid/raw/master/changelog.md
       
      Module status: alpha, License: MIT
      Note that every installation and uninstallation sends an anonymous google analytics event to my google analytics account. If you don't want that feel free to remove the appropriate lines of code before installation/uninstallation.
       
      Contribute:
      You can contribute to the development of this and other modules or just say thank you by
      testing, reporting issues and making PRs at gitlab liking this post buying me a drink: paypal.me/baumrock/5 liking my facebook page: facebook.com/baumrock hiring me for pw work: baumrock.com  
      Support: Please note that this module might not be as easy and plug&play as many other modules. It needs a good understanding of agGrid (and JavaScript in general) and it likely needs some looks into the code to get all the options. Please understand that I can not provide free support for every request here in the forum. I try to answer all questions that might also help others or that might improve the module but for individual requests I offer paid support (please contact me via PM).
       
      Use Cases / Examples:
      Colored grid cells, Icons, Links etc. The Grid also has a "batcher" feature built in that helps communicating with the server via AJAX and managing resource intensive tasks in batches:

      Filters, PW panel links and instant reload on panel close:

      You can combine the grid with a chart library like I did with the (outdated) RockDataTables module:

    • By Paul Greinke
      Hi there. I wrote a custom module for one of my projects. In fact I maybe want to use my module in other projects too. In order to be variable and customizable  I need to implement some custom hooks into my module. So I can afterwards hook into the my functions in order to modify them to match the needs of the new project.
      I tried simply defining functions with the '__' prefix. But that did not work. I'm imagining something like the following:
      <?php class MyClass { public function ___someFunction() { // Do something } } // ready.php $this->addHookBefore('MyClass::someFunction', function($event) { // some customization }); Is there a way to accomplish that? 
×
×
  • Create New...