Jump to content
kongondo

Menu Builder

Recommended Posts

On 6/13/2019 at 4:31 PM, uiui said:

Has anyone ever had the issue that changes to a menu won't save anymore? After adding page number 89 moving items isn't possible anymore as the change won't be saved. This is the case independent of the last page I add or where I move that page.

We had this issue recently, it's because of the limit of Input variables in your PHP configuration. Adjusting the value of max_input_vars in your php.ini file to a larger number will increase the number of items you can save 🙂

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
21 minutes ago, Asimov said:

We had this issue recently, it's because of the limit of Input variables in your PHP configuration. Adjusting the value of max_input_vars in your php.ini file to a larger number will increase the number of items you can save 🙂

Thanks @Asimov ! Excellent response! Welcome to the forums.

Share this post


Link to post
Share on other sites

Hello,

I need some help please. 😉 With "configuring the menu" and adding some additional stuff to my mobile menu, but not really sure how to do that.

I would like my Logo to show in my mobile menu, and I would also like the language switcher there, but cant figure it out. I tried all sorts of things but cant make it work.

My html looks like this: In html the logo is there, but when I try tu give it to menubuilder code it is gone. 

Spoiler

    <nav id="ro-main-nav" class="ro-main-nav-style-1">
      <div class="container">
        <div class="ro-brand"><a href="index.html"><img src="javascript:if(confirm('http://mysite.com/images/logo.svg\n\nThis file was not retrieved because it was filtered out by your project settings.\n\nWould you like to open it from the server?'))window.location='http://mysite.com/images/logo.svg'" alt="Logo"/><img src="javascript:if(confirm('http://mysite.com/images/logo.svg\n\nThis file was not retrieved because it was filtered out by your project settings.\n\nWould you like to open it from the server?'))window.location='http://mysite.com/images/logo.svg'" alt="Logo"/></a></div>
        <ul class="ro-nav-content text-center">
          <li class="visible-xs"><a href="index.html"><img src="javascript:if(confirm('http://mysite.com/images/logo.svg\n\nThis file was not retrieved because it was filtered out by your project settings.\n\nWould you like to open it from the server?'))window.location='http://mysite.com/images/logo.svg'" alt="Logo"/></a></li>
          <li><a href="index.html">HOME</a>
            <ul class="ro-sub-nav">
              <li><a href="basic.html">Link 1</a></li>
              <li><a href="fullwidth.html">Link 2</a></li>
              <li><a href="fullheight.html">Link 3</a></li>

            </ul>
          </li>
          <li><a href="about.html">PAGES</a>
            <ul class="ro-sub-nav">
              <li><a href="about.html">About Us</a></li>
              <li><a href="404.html">Page 2</a></li>
            </ul>
          </li>
          <li><a href="service.html">SERVICES</a></li>
          <li><a href="shop.html">SHOP</a>
            <ul class="ro-sub-nav">
              <li><a href="product.html">Product Page</a></li>
              <li><a href="cart.html">Page</a></li>
              <li><a href="checkout-1.html">Also page</a></li>
            </ul>
          </li>
          <li><a href="contact.html">CONTACT</a></li>
        </ul>
        <div id="ro-hamburger" class="ro-hamburger visible-xs pull-right"><span></span></div>
      </div>
    </nav>

I've tried with:

Spoiler

<nav id="ro-main-nav" class="ro-main-nav-style-1">
      <div class="container">
        <div class="ro-brand"><a href="<?=$config->urls->root;?>"><img src="<?=$pages->get("/Nastavitve/")->header_logo->url?>'" alt="logo"/></a></div>
          <?php 
                        $menu = $modules->get('MarkupMenuBuilder');
                        $options = array(

                            'wrapper_list_type' => 'ul',// ul, ol, nav, div, etc.
                            'list_type' => 'li',// li, a, span, etc.
                            'menu_css_id' => '',// a CSS ID for the menu
                            'menu_css_class' => 'ro-nav-content text-center',// a CSS Class for the menu
                            'submenu_css_class' => 'ro-sub-nav',// CSS Class for sub-menus
                            'has_children_class' => 'ro-sub-nav',// CSS Class for any menu item that has children
                            'first_class'=>'',// CSS Class for the first item in 
                            'last_class' => '',
                            'current_class' => 'active',
                            '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' => 1,// how deep to fetch 'include_children'
                            'current_class_level' => 1,// how high up the ancestral tree to apply 'current_class'
                            'default_class' => '',// a CSS class to apply to all menu items
                        );
                        echo $menu->render(1163, $options);
                        ?>

        <div id="ro-hamburger" class="ro-hamburger visible-xs pull-right"><span></span></div>
      </div>
    </nav>

but there is no logo inside. I also tried with both upper codes and added images to them but not working.

And second question, I would also like to put language switcher to it, not sure how to combine this ...

Spoiler

<ul class="ro-nav-content text-center">
<?php
$savedLanguage = $user->language;

foreach($languages as $language) {
  if($language->id == $savedLanguage->id) continue;
  if(!$page->viewable($language)) continue;
  $user->language = $language;
  echo "<li><a href='$page->url'>$language->title</a></li>";
}
$user->language = $savedLanguage;

?>
</ul>

I hope u understand what Im trying to do. Any help would be appreciated. 😉

Thank you

R

Share this post


Link to post
Share on other sites

HI there, 

Very nice module thank you.

I would like to put a class in each of the ul of the sub menus I have in my menu. It seems that through the admin interface or the $option of the render() function I can't achieve this. Is this correct ?

Then would the only  way to do this is the getMenuItems() function and coding the menu's markup ?

Thanks 

Share this post


Link to post
Share on other sites

ok... I am answering my own (stupid) question in case it's of any help to somebody.

To add a class in the ul of each submenu. Use the 'submenu_css_class' in the $option array. 

Share this post


Link to post
Share on other sites

Hey guys, I've been using the MenuBuilder for quite a few projects (thanks @kongondo for the great module and support!), however this time it is my first when I need to use a menu in the sidebar if some pages are added to it. It all works as soon as I add a few items to the menu, however there is one little issue I am having - not knowing how to show the block title ONLY if the menu contains some items added. I've been looking through the module functions etc. to figure it out, however for some reason I am always getting the items count as 1 even though I've added 9.

<?php
        //Building the array of options. The ones that are not used can be removed
        //They are left here for the learning process only.
        $options = array(
         'wrapper_list_type' => 'ul',// ul, ol, nav, div, etc.
         'list_type' => 'li',// li, a, span, etc.
         'menu_css_id' => '',// a CSS ID for the menu
         'menu_css_class' => 'category-list',// a CSS Class for the menu
         'current_class' => 'active',
         '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' => 1,// how deep to fetch 'include_children'
         'current_class_level' => 1,// how high up the ancestral tree to apply 'current_class'
        );

        // Render the menu by title
        $cat_menu = $menu->render(1108, $options);
        echo "This menu has: " . count($cat_menu);
        echo $cat_menu;

       ?>	

The big question here is, how can I add a check if my menu with a specific ID/title would contain some items or is just empty in order to show or not the block title etc.?

Share this post


Link to post
Share on other sites
On 12/4/2019 at 3:02 AM, MilenKo said:

Hey guys, I've been using the MenuBuilder for quite a few projects (thanks @kongondo for the great module and support!),

Hi @MilenKo. Apologies for the late response.

I am not sure what you mean by block title.

However, this count() will not work:

echo "This menu has: " . count($cat_menu);

as $menu->render() returns a string. PHP will return 1 (a boolean) but if you had Tracy Debugger it would throw an error about using count() on a non-iterable variable.

If you need to know the number of items you can use the method getMenuItems() introduced here and documented here. You can use the method to either return menu items as a an normal PHP array or as a WireArray. In the examples outlined in the first link above, you can use getMenuItems() with a custom recursive function to render your menu however you wish. In your case though, you can just use it to check number of items. For example:

$mb = $modules->get('MarkupMenuBuilder');
// menu items as PHP Array
$menuItemsAsArray = $mb->getMenuItems(1108, 1, $options);// param 2 = 1: return array
echo 'Number of Menu Items (count($menuItemsAsArray)): ' .  count($menuItemsAsArray);
// menu items as WireArray Object
$menuItemsAsObject = $mb->getMenuItems(1108, 2, $options);// param 2 = 2: return WireArray (the default)
echo 'Number of Menu Items ($menuItemsAsObject->count): ' .  $menuItemsAsObject->count;

In case you just want to know if a menu item is not empty, you can simply check if the return value of $cat_menu is a string. For example:

 // Render the menu by title
 $cat_menu = $menu->render(1108, $options);
 if(is_string( $cat_menu)) {
	echo $cat_menu;
 }

This, however, will not give you the count as explained above. You'd need getMenuItems() for that.

In case you want to know if a menu item is a parent/has children, etc, you can use the WireArray option of getMenuItems() as shown above and use ProcessWire WireArray methods to filter items. For instance:

$someChildItems = $menuItemsAsObject->find("parentID=2");
// OR
$someParents = $menuItemsAsObject->find("isParent=1");

I hope this helps.

Share this post


Link to post
Share on other sites

/site/modules/ProcessMenuBuilder/ProcessMenuBuilder.css

178 line

div.handle i.fa-trash {
    position: relative;
    border: none;
    padding: 0.6em;
    /*margin-right: -2.125em;*/
    top: 1px;
}

fix: add comment margin

 

Знімок екрану.png

  • Like 2

Share this post


Link to post
Share on other sites
36 minutes ago, duncan said:

fix: add comment margin

Thanks. I only noticed this yesterday but have not had time to fix it.

Share this post


Link to post
Share on other sites

Hi guys, hi @kongondo,

I have a menu which I built using your code from some pages back:

Quote

function buildMenuFromObject($parent = 0, $menu, $first = 0) {
    if(!is_object($menu)) return;

    $out = '';
    $has_child = false;

    foreach ($menu as $m) {
        $newtab = $m->newtab ? " target='_blank'" : '';
        // if this menu item is a parent; create the sub-items/child-menu-items
        if ($m->parentID == $parent) {// if this menu item is a parent; create the inner-items/child-menu-items
            // if this is the first child
            if ($has_child === false) {
                $has_child = true;// This is a parent
                if ($first == 0){
                    $out .= "<ul class='mainMenu js-mainMenu clearfix'>\n";
                    $first = 1;
                }
                else $out .= "\n<ul class='subMenu js-subMenu'>\n";
            }

            $class = $m->isCurrent ? ' class="current"' : '';

            // a menu item
            $out .= '<li' . $class . '><a href="' . $m->url . '"' . $newtab . '>' . $m->title;
            // if menu item has children
            if ($m->isParent) {
                $out .= '</a><span class="icon submenu__expand js-submenu__expand icon-cheveron-down"></span>';
            }

            else $out .= '</a>';

            // call function again to generate nested list for sub-menu items belonging to this menu item.
            $out .= buildMenuFromObject($m->id, $menu, $first);
            $out .= "</li>\n";

        }// end if parent

    }// end foreach

    if ($has_child === true) $out .= "</ul>\n";

    return $out;

}

 

which works fine, although I have a question regarding the submenus. I have selected to include all native descendants of my page into the submenu. which generates something like this:

<ul>
  <li> Projects </li>
  <ul class="submenu">
  	<li class="submenuItem">
      Project 1
    </li>
    <li class="submenuItem">
      Project 2
    </li>
    ... -> render all remaining Project objects which are children of the Projects Page
  </ul>

This, however, bloats my submenu, if I have a lot of projects. Is there some option to limit the amount of projects that are rendered, to e.g. 10 and then provide a link as the last project item which leads to a project list view which displays all projects?

I just don't quite get the code; e.g. where the code fetches the native descendants of the ``projects`` page.

Any help would be appreciated.

Greetings, derelektrischemoench

Share this post


Link to post
Share on other sites

Update: Menu Builder 0.2.6

Changelog

  1. Added the properties numChildren, totalChildren and showMoreText for use with getMenuItems()
  2. Added option maximum_children_per_parent to limit the maximum number of (included) children a menu item can return. Thanks @derelektrischemoench for inspiration/request.
  3. Fixed CSS issue that affected menu items' trash cans in the backend. Thanks @duncan.
  4. Refactored code to improve efficiency.

In dev branch only for testing.

I have also updated the docs, especially around getMenuItems().

@derelektrischemoench,

See this gist for an example recursive menu builder function that uses maximum_children_per_parent and showMore.

OK, breaktime over, back to Padloper! :-).

  • Like 2

Share this post


Link to post
Share on other sites
On 12/17/2019 at 1:44 PM, kongondo said:

Update: Menu Builder 0.2.6

Changelog

  1. Added the properties numChildren, totalChildren and showMoreText for use with getMenuItems()
  2. Added option maximum_children_per_parent to limit the maximum number of (included) children a menu item can return. Thanks @derelektrischemoench for inspiration/request.
  3. Fixed CSS issue that affected menu items' trash cans in the backend. Thanks @duncan.
  4. Refactored code to improve efficiency.

In dev branch only for testing.

I have also updated the docs, especially around getMenuItems().

@derelektrischemoench,

See this gist for an example recursive menu builder function that uses maximum_children_per_parent and showMore.

OK, breaktime over, back to Padloper! :-).

Hi Kongondo,

thanks for including my input and change requests :) very cool! I'm gonna give it a try, asap.

Greetings

derelektrischemoench

Share this post


Link to post
Share on other sites

Hi kongondo and hi all guys!

Is there a way to put a new field (ex: description) on each menu entries? I like to have something like:


Title: Home
Description: My beautiful home page
URL: /my-beautiful-url/

I wait your feedback.

Thanks and have a nice day!

Share this post


Link to post
Share on other sites
On 1/8/2020 at 5:52 PM, e0f said:

Is there a way to put a new field (ex: description) on each menu entries? I like to have something like:


Title: Home
Description: My beautiful home page
URL: /my-beautiful-url/

I wait your feedback.

Thanks and have a nice day!

Hi @e0f,

Currently, this is not doable out of the box. However, using the method getMenuItems() (see a few posts up for examples), you can use the property pagesID (or index pages_id if getting back array of menu items) to get ($pages->get($m->pageID), for example) the respective ProcessWire pages of the menu items and return the custom fields you want, e.g. description. Having said that, I would not recommend this. It seems like an overkill and may not be very performant based on the number of menu items and other factors.

Perhaps if you could explain your use case, I would see if I can add an option to retrieve the values of simple fields (text, integers, dates, etc) for use with getMenuItems(). MenuBuilder is primarily for building navigation menus. From your example, it seems you are using it for a different purpose? Maybe provide a fuller example so that I can get my head around this.

  • Like 1

Share this post


Link to post
Share on other sites
12 hours ago, kongondo said:

Hi @e0f,

Currently, this is not doable out of the box. However, using the method getMenuItems() (see a few posts up for examples), you can use the property pagesID (or index pages_id if getting back array of menu items) to get ($pages->get($m->pageID), for example) the respective ProcessWire pages of the menu items and return the custom fields you want, e.g. description. Having said that, I would not recommend this. It seems like an overkill and may not be very performant based on the number of menu items and other factors.

Perhaps if you could explain your use case, I would see if I can add an option to retrieve the values of simple fields (text, integers, dates, etc) for use with getMenuItems(). MenuBuilder is primarily for building navigation menus. From your example, it seems you are using it for a different purpose? Maybe provide a fuller example so that I can get my head around this.

Thanks for answer kongondo.

I need to have a little description appear under my mega menu.

In frontend menu I'll have something like "Home" and under it a little description of the menu entry (ex: my beautiful home page).

So each menu voices will have a custom description on desktop version.

I hope is all clear now. Let me know if you need more infos!

Have a nice day,

Share this post


Link to post
Share on other sites

Update: Menu Builder 0.2.7

Changelog

  1. Added the property extra_fields for use with getMenuItems() ONLY. This enables returning the page field values for some selected Fieldtypes. For example, the description field in the page corresponding to the menu item. Thanks @e0f for the inspiration. Full documentation of this new feature is available here.
  2. Menus in multi-lingual sites can now be called using their multi-lingual titles or names irrespective of the current user's language. For example, a multi-lingual site with English, German and Finnish languages could have a menu with the respective titles My Awesome Menu / Mein Tolles Menü / Oma Mahtava Valikko. Any of these titles can be used in the code to call the menu (using render() or getMenuItems() methods). [PS: blame you-know-who for these language translations :-)]
  3. Changed the way new menus are added. Only one menu can be added at a time. The title field/input is multi-lingual ready. See screens below.
  4. Improved the backend GUI when viewing locked menus. Only the menu items and and exit button are shown in such cases.
  5. Fixed bug that allowed access to unpublished menus for frontend rendering.
  6. Updated the documentation
  7. Refactored code to improve efficiency.

In dev branch only for testing.

Screenshots

a. Add Menu (Multi-lingual)

mb-version-27-add-menu-multilingual-screen.thumb.png.1c5654f2eae1e95c5fcee2b4baf5f1d1.png

 

b. Edit Menu (Multi-lingual)

mb-version-27-edit-menu-multilingual-screen.thumb.png.2c5d93ef748b5b9298f51d4ed67ee366.png

c. Locked Menu

mb-version-27-locked-menu-screen.thumb.png.991346ad1977d5d2216c2c872ed96e95.png

d. An example usage of extra_fields (I am no designer, so yeah, nothing much to see here...but you get the idea :-))

mb-version-27-extra-fields-screen.thumb.png.4f981af877a394d4d2175f0294b1181d.png

 

Thanks for testing!

  • Like 2

Share this post


Link to post
Share on other sites

i added new option in menu options because i needed css class in <a> tag, searched for a while and didn't find any example so had to do the following.

$NavOptions = array(
                                'wrapper_list_type' => 'ul', // ul, ol, nav, div, etc.
                                'list_type' => 'li', // li, a, span, etc.
                                'menu_css_id' => 'navbarSupportedContent', // a CSS ID for the menu
                                'menu_css_class' => 'navbar-nav ml-auto', // a CSS Class for the menu
                                'current_class' => 'active',
                                'default_title' => 0, // 0=show saved titles;1=show actual/current titles
                                'default_class' => 'nav-item', // a CSS class to apply to all menu items
                                'ahref_class'=>'nav-link'
                            );

 

added following line in MarkupMenuBuilder.module
$this->set('linkClass', isset($options['ahref_class']) ? $options['ahref_class'] : '');

// 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}' class='{$o->linkClass}'>{$m->title}</a>";

suggest me if there is any better way out!!

  • Like 2

Share this post


Link to post
Share on other sites

Welcome to the forums @Neeraz,

5 hours ago, Neeraz said:

because i needed css class in <a> tag,

It was decided early on to add classes to the <li> instead of the <a>, as it was the usual practice.

6 hours ago, Neeraz said:

suggest me if there is any better way out!!

Getting the <a> via CSS is quit easy, for instance...

#menu li a {
/* your styles here*/
}

You can be as specific as  you want with your CSS.

6 hours ago, Neeraz said:

added following line in MarkupMenuBuilder.module

Not a good idea as this will get overwritten next time you upgrade Menu Builder :-).

Share this post


Link to post
Share on other sites
8 hours ago, kongondo said:

Welcome to the forums @Neeraz,

It was decided early on to add classes to the <li> instead of the <a>, as it was the usual practice.

Getting the <a> via CSS is quit easy, for instance...


#menu li a {
/* your styles here*/
}

You can be as specific as  you want with your CSS.

Not a good idea as this will get overwritten next time you upgrade Menu Builder :-).

i know this but i have no permission to modify customer css file so had to do this, i suggest you to add the same option in future update so it will be more flexible 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Hi there,

I'm with @Neeraz - it would be great to have the possibility to also add a class to the link element (for what reason ever).
Maybe @kongondo it is not a big deal for you to add that functionality to the module? That would be great 👌.

Have a nice Friday 😉

  • Like 2

Share this post


Link to post
Share on other sites

Just a question that might be answered in a previous post. If I want to apply a class to the <a> tag how would I do this using the module options?

Share this post


Link to post
Share on other sites

Using this module for the first time, menu created and saved but does not render. Looks like by default it's saved as un-published.

I was expecting to find publish settings as part of the menu settings, however the only way to publish it is via the page tree: Admin > Setup > Menu Builder > *Menu*
Is this intentional? I think from a usability perspective being able to publish the menu as you create it would be helpful.

The only way I could get menu builder to render items was update line 218, MarkupMenuBuilder to:
For some unknown reason, PW doesnt skip language.

// skip inactive language page @note: PW will do this automatically for 'include_children'
                if(!$p->viewable($language&& $languagecontinue;

Share this post


Link to post
Share on other sites
On 2/5/2020 at 5:55 AM, Neeraz said:

i know this but i have no permission to modify customer css file so had to do this, i suggest you to add the same option in future update so it will be more flexible

 

On 2/21/2020 at 8:27 AM, Bacelo said:

Maybe @kongondo it is not a big deal for you to add that functionality to the module? That would be great 👌.

OK. Added to my todo 😀

Share this post


Link to post
Share on other sites
16 hours ago, Mackski said:

the only way to publish it is via the page tree: Admin > Setup > Menu Builder > *Menu*

Actually, this is not true 😀.

I don't know what version you are using but there has always been a save as unpublished or published during menu creation and an unpublish/publish action that can be applied to existing menu items in the menus list/table. See the big green shiny buttons 😁.

Create menu before version 027 

mm_add_new_menu_versions_less_than_027.thumb.png.abef7bcbff9f1c31e4add8ea310b46ff.png

Create menu version since version 027

mm_add_new_menu_versions_from_027.thumb.png.5215c34d9985bcd69fa85b42a36c0f81.png

Unpublish/Publish post menu creation

mm_unpublish_publish_existing_menu.thumb.png.8bdbddb85f2161f191d1144be8d7e145.png

Am I missing something?

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 MoritzLost
      This module allows you to integrate hCaptcha bot / spam protection into ProcessWire forms. hCaptcha is a great alternative to Google ReCaptcha, especially if you are in the EU and need to comply with privacy regulations.

      The development of this module is sponsored by schwarzdesign.
      The module is built as an Inputfield, allowing you to integrate it into any ProcessWire form you want. It's primarily intended for frontend forms and can be added to Form Builder forms for automatic spam protection. There's a step-by-step guide for adding the hCaptcha widget to Form Builder forms in the README, as well as instructions for API usage.
      Features
      Inputfield that displays an hCaptcha widget in ProcessWire forms. The inputfield verifies the hCaptcha response upon submission, and adds a field error if it is invalid. All hCaptcha configuration options for the widget (theme, display size etc) can be changed through the inputfield configuration, as well as programmatically. hCaptcha script options can be changed through a hook. Error messages can be translated through ProcessWire's site translations. hCaptcha secret keys and site-keys can be set for each individual inputfield or globally in your config.php. Error codes and failures are logged to help you find configuration errors. Please check the README for setup instructions.
      Links
      Github Repository and documentation InputfieldHCaptcha in the module directory (pending approval) Screenshots (configuration)

      Screenshots (hCaptcha widget)

       
       

       
    • 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
×
×
  • Create New...