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 joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.1.1 Debugging: fixed error during uninstall 0.1.0 Added new detection of async scripts for W3C Validation 0.0.6 CSS-Debugging for hiding unused buttons, added ProCache support for the JavaScript tag 0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
×
×
  • Create New...