Jump to content
Soma

MarkupSimpleNavigation

Recommended Posts

When rendering two navs on the same page it seems that the first interferes with the second.

If my first nav is...

$menu = $modules->get("MarkupSimpleNavigation");
$items = $pages->find("parent=news");
echo $menu->render(null, null, $items);

...and then my second nav is...

echo $menu->render();

...then that second nav only shows children of news even though no PageArray is passed in to the render method.

Even if my second nav is...

$second_menu = $modules->get("MarkupSimpleNavigation");
echo $second_menu->render();

...it still seems to be limited by the PageArray of the first nav.

Can someone explain where I'm going wrong here? Thanks.

Share this post


Link to post
Share on other sites

I think I see what is causing this but don't fully understand yet as with a new instance it shouldn't be limited by the first. A second call with no arguments it should default to "null" but looks like it's somehow saved but don't get how this happens.

In my quick test It's only if you use a PageArray as root page. If using only 1 page as the root it doesn't happen. 

So for a quick solution you just have to explicit set the root page or items.

Share this post


Link to post
Share on other sites

I think I found the problem a pushed a fix and it's now v 1.3.4. Good find, thanks for the mention.

Share this post


Link to post
Share on other sites

Hello,

I've been testing MarkupSimpleNavigation for the first time yesterday.

I had been testing some pieces of code found in the ProcessWire Forums and in some profiles just before deciding to finally try it.

But for the moment, I'm stuck with the same obstacles.

I have a first horizontal menu with only the homepage and its children(1) (I will see if I remove the homepage later).

Just below I would like a second horizontal menu with the children(2) of a child(1) appearing when their parent is active.

But, I would need the children(2) not to disappear when clicking on one of them.

Is it possible, and without having to create a different template?

Thanks in advance for some help.

Here is the current second menu (but I've tried several variations with the first and second menus):

<?php
        if($page->template != "home") {
            $subMenu = $modules->get("MarkupSimpleNavigation"); // load the module
            $rootPage = $page;
            echo $subMenu->render(null, null, $rootPage); // render default submenu           
        }
    ?>

Share this post


Link to post
Share on other sites

Hello Soma,

Where can version 1.3.4 be found?

Perhaps it can help solve my "issue".

Have a nice day!

Share this post


Link to post
Share on other sites

you have no issue here - you've just say the module what pages to show....so if you have a spitted menu with

topmenu 

_______ |

content   | sidebarmenu

               |

you could switch to show childpages to siblings so the submenu is there if you select a subpage of a mainmenu item.

//sideBarMenuNav change items to view 
if($page->hasChildren) {  //we are on a first level parent page so show sencond level
$entries = $page->children;
} else {   //we are on second level so show siblings to actual page
$entries = $page->siblings;
};

using the menu i always show all options to easy change settings and/or see at first glance what is set...

//just a example from one of my websites...see max_levels, show_root and other options here
//markup is fitting for a bootstrap pill subnavigation...

$sideBarMenu = $modules->get("MarkupSimpleNavigation"); // load the module
	$options = array(
		'parent_class' => 'parent',		// overwrite class name for current parent levels
		'current_class' => 'active',	// overwrite current class
		'has_children_class' => 'has_children',    // overwrite class name for entries with children
		'levels' => true,    // wether to output "level-1, level-2, ..." as css class in links
		'levels_prefix' => 'level-',    // prefix string that will be used for level class
		'max_levels' => 2,    // set the max level rendered
		'firstlast' => false,    // puts last,first class to link items
		'collapsed' => false,    // if you want to auto-collapse the tree you set this to true
		'show_root' => false,    // set this to true if you want to rootPage to get prepended to the menu
                'selector' => 'template!=settings',    // define custom PW selector, you may sanitize values from user input
		'selector_field' => 'nav_selector',    // string (default 'nav_selector') define custom PW selector by using a property or field on a page. Use this setting if you want to overwrite the default nav_selector
		'outer_tpl' => '<ul class="nav nav-pills nav-stacked">||</ul>',    // template string for the outer most wrapper. || will contain entries
		'inner_tpl' => '<ul>||</ul>',    // template string for inner wrappers. || will contain entries
		//'list_tpl' => '',    // template string for the items. || will contain entries, %s will replaced with class="..." string
		'list_field_class' => '',  // string (default '') add custom classes to each list_tpl using tags like {field} i.e. {template} p_{id}
		'item_tpl' => '<a href="{url}#start">{title}</a>',    // template string for the inner items. Use {anyfield} and {url}, i.e. {headline|title}, if field is of type image it will return url to image (first image if multiple)
		'item_current_tpl' => '<a href="{url}#start">{title}</a>',    // template string for the active inner items.
		'xtemplates' => '',    // specify one or more templates separated with a pipe | to use the xitem_tpl and xitem_current_tpl markup
		'xitem_tpl' => '',    // same as 'item_tpl' but for xtemplates pages, can be used to define placholders
		'xitem_current_tpl' => '',    // same as 'item_current_tpl' but for xtemplates pages
		'date_format' => 'Y/m/d',    // default date formatting for Datetime fields and native created/modified
		'code_formatting' => true,    // enable or disable code indentations and newslines in markup output
		'debug' => false,    // show some inline information about rendertime and selectors used as html comments
	);
$sideBarNav = $sideBarMenu->render($options, null, $entries);

regards mr-fan

study all the options kindly (RTFM :rolleyes: ) before getting into an issue - this module with all the options is very very powerfull!

  • Like 1

Share this post


Link to post
Share on other sites

@Christophe

I think in your second menu you want

$rootPage = $page->rootParent;
  • Like 2

Share this post


Link to post
Share on other sites

Hello Soma,

Where can version 1.3.4 be found?

Perhaps it can help solve my issue.

Have a nice day!

Ah sorry, it seems I haven't commited it yet or forgot it... It's now updated.

  • Like 1

Share this post


Link to post
Share on other sites

@mr-fan: I don't know why I didn't try with an if...else statement. Perhaps I had been too long on the computer...

I also have a commented version for the first menu.

@Cerulean: this time, just using $rootPage = $page->rootParent; is enough.

It's possible I used $rootParent here or somewhere else once without really knowing what I was doing, but then changed it as I was testing things in multiple tabs, and couldn't find it back later.

And perhaps I also did like just now: I forgot to upload the file again in FileZilla.

Thank you both!

I will also later look (if and) how I can use Drop Jumbo [ http://cferdinandi.github.io/drop/ ] with MarkupSimpleNavigation.

(The Drop Basic demo is going to be fixed. It seems that, since the new version and website were released a few days ago, it doesn't work anymore.)

Share this post


Link to post
Share on other sites

@soma

I was trying to add an image to the left of each navigation link.

As your docs mention, the following will grab the first image in a field I specify

'item_current_tpl' => '<div class="nav-icon"><img src="{images}"></div><a href="{url}">{title}</a>',

I had a few challenges here and wondered about best approach

Image Tag

My images field may contain several images. I could create a separate navigation_images field but would love to call an image by tag

Image size

I can accomplish by CSS but wondered if I could apply the API width() 

Ultimately, my markup would resemble something like this. It's the getTag and width(300) which break the call

'item_current_tpl' => '<div class="nav-icon"><img src="{images->getTag('icon')->width(300)->url}"></div><a href="{url}">{title}</a>',

Share this post


Link to post
Share on other sites

Wondered if I was along the right track with following.

I associate a variable with my image tag including width:

$myimage = $page->images->getTag('icon')->width(300)->url;

and then in the MarkupSimpleNavigation refer to $myimage in the item_crrent_tpl line

'item_current_tpl' => '
<div class="nav-icon"><img src="{myimage}"></div><a href="{url}">{title}</a>
',

Share this post


Link to post
Share on other sites

Eventually solved this with the help of a mate who is an experienced PHP developer.

<?php $treeMenu = $modules->get("MarkupSimpleNavigation");
		  
$myimage = $page->images->getTag('icon')->width(50)->url;	
		
$options = array(
'item_current_tpl' => '<div class="nav-icon"><img src="'.$myimage.'"></div><a href="{url}">{title}</a>',
; 
?>	

We both acknowledge that a better solution is most likely to use the Hook method outlined in the Module readme but I needed something quick (approaching deadline) that I could relate to and maintain myself.

Given time I may look more closely at the Hook method and try understand that a bit more.

Share this post


Link to post
Share on other sites

like i wrote i've added a kind of megamenu (even with images and last articles) with hooks...i'm not at home now but i will prepare a example on this...;)

Share this post


Link to post
Share on other sites

@Peter Knight - won't $myimage always be the icon for the current page?

$myimage = $page->images->getTag('icon')->width(50)->url;    

or does the $page context change inside the MSN loop? ... curious about your solution

Share this post


Link to post
Share on other sites

@Peter Knight - won't $myimage always be the icon for the current page?

or does the $page context change inside the MSN loop? ... curious about your solution

Each pages navigation link has an icon. 

Share this post


Link to post
Share on other sites

right, that's good to know (nevermind my dumb question)... i guess MSN changes the $page context, even though you set the variable outside of the options...in other words $page when in options means the menu item page, not the page being viewed;

Share this post


Link to post
Share on other sites

Eventually solved this with the help of a mate who is an experienced PHP developer.

<?php $treeMenu = $modules->get("MarkupSimpleNavigation");
		  
$myimage = $page->images->getTag('icon')->width(50)->url;	
		
$options = array(
'item_current_tpl' => '<div class="nav-icon"><img src="'.$myimage.'"></div><a href="{url}">{title}</a>',
; 
?>	

We both acknowledge that a better solution is most likely to use the Hook method outlined in the Module readme but I needed something quick (approaching deadline) that I could relate to and maintain myself.

Given time I may look more closely at the Hook method and try understand that a bit more.

That's seems like a viable solution, but only for the active current page. You also just set the "item_current_tpl" and that's only for the current active page. If that's the idea that's ok. 

MarkupSimpleNavigation doesn't change any page context at all. So the $page you have there's is only the current page viewing.

When working with a hook, you would have to check for current page with

if($child === wire("page")) {
    // do your markup logic
}

Taking the example from the readme I linked earlier it would be like:

$nav = $modules->get("MarkupSimpleNavigation");

function myItemString(HookEvent $event){
    // the current rendered child page
    $child = $event->arguments('page'); 
    
    // if current child you're viewing
    if($child === wire("page")) { 
        $myimage = $child->images->getTag('icon')->width(50);
        $itemMarkup = "<div class='nav-icon'><img src='{$myimage->url}'></div><a href='{$child->url}'>{$child->title}</a>";
        $event->return .= $itemMarkup; // send back the markup that will present a item
    }
}

// setup the hook
$nav->addHookAfter('getItemString', null, 'myItemString');

// a render will then also trigger the hook above on each item
echo $nav->render(); 

This would allow to have all different logic in your output depending on custom criterias

  • Like 2

Share this post


Link to post
Share on other sites

Hi - Can someone tell me what options I would need to modify to get MSN to output below menu?

  <select id="mobile-nav">
                  <option>Select page:</option>

                  <option value="index.html">Home</option>
                    <option value="index.html">  Default Layout</option>
                  <option value="about.html">About</option>
                  <option value="blog_right.html">Blog</option>
                    <option value="blog_right.html">  Right sidebar - 1</option>
                    <option value="blog_right2.html">  Right sidebar - 2</option>
                    <option value="blog_post.html">  Blog Post</option>
        <option value="simplecodes_columns.html">Simple Codes</option>
          <option value="simplecodes_columns.html">  Columns</option>
        <option value="portfolio_three1.html">Portfolio</option>
          <option value="portfolio_one1.html">  One Column 1</option>
          <option value="portfolio_three1.html">  Three Columns 1</option>
        <option value="contact.html">Contact</option>

                </select>

Share this post


Link to post
Share on other sites

Seems like a weird menu or I don't get it. If it's for a menu, why it needs a "Select page"?

I'm not sure MSN is made for that task if it's a nested menu structure cause it used UL//OL style nesting that isn't the same as a Select menu would require. I haven't tried but maybe something like this works for a single level menu.

$nav = $modules->MarkupSimpleNavigation;

$options = array(
    "outer_tpl" => "||",
    "list_tpl" => "||",
    "item_tpl" => "<option value='{url}'>{title}</option>",

);

$content .= "<select id='mobile-nav'>";
$content .= "<option>Select</option>";
$content .= $nav->render($options);
$content .= "<select id=''>";

There's JS plugins that can make a Select menu out of a UL list menu.

Share this post


Link to post
Share on other sites

That's seems like a viable solution, but only for the active current page. You also just set the "item_current_tpl" and that's only for the current active page. If that's the idea that's ok. 

Macrura and Soma - you're both correct. My code only works for the current page. I hadn't realised earlier as I was testing and viewing a single page which just happened to be my current page :-/

Moving on, I've worked Somas example into my template, updated the field names etc to produce the following.

As Soma mentioned, this displays an icon only for the current page.

<?php $nav = $modules->get("MarkupSimpleNavigation");

function myItemString(HookEvent $event){
    // the current rendered child page
    $child = $event->arguments('page'); 
    
    // if current child you're viewing
    if($child === wire("page")) { 
        $myimage = $child->nav_icon;
        $itemMarkup = "<div class='nav-icon'><img src='{$myimage->url}'></div><a href='{$child->url}'>{$child->title}</a>";
        $event->return .= $itemMarkup; // send back the markup that will present a item
    }
}

// setup the hook
$nav->addHookAfter('getItemString', null, 'myItemString');

// the navigation options
$options = array(

  'parent_class' => 'parents',
  'current_class' => 'current',
  'has_children_class' => 'has_children',
  'levels' => true,
  'levels_prefix' => 'level-',
  'max_levels' => 1,
  'firstlast' => true,
  'collapsed' => false,
  'show_root' => true,
  'selector' => '',
  'selector_field' => 'nav_selector',
  'outer_tpl' => '<ul class="sidelist">||</ul>',
  'inner_tpl' => '<ul>||</ul>',
  'list_tpl' => '<li%s >||</li>',
  'list_field_class' => '',
  'item_tpl' => '<a href="{url}">{title}</a>',
  'item_current_tpl' => '<a href="{url}">{title}</a>',
  'xtemplates' => '',
  'xitem_tpl' => '<a href="{url}">{title}</a>',
  'xitem_current_tpl' => '<span>{title}</span>',
  'date_format' => 'Y/m/d',
  'code_formatting' => false,
  'debug' => false
);

$root = $page->rootParent; // Start from the top root parent of current page
// a render will then also trigger the hook above on each item
echo $nav->render($options, null, $root); 
?>	

The key to getting my menu to produce a unique icon per page seemed to be removing the if($child === wire("page"))

function myItemString(HookEvent $event){
    // the current rendered child page
    $child = $event->arguments('page'); 
    
    
        $myimage = $child->nav_icon;
        $itemMarkup = "<div class='nav-icon'><img src='{$myimage->url}'></div><a href='{$child->url}'>{$child->title}</a>";
        $event->return .= $itemMarkup; // send back the markup that will present a item
   
}

My only problem at the moment is that each navigation link is being output twice.

post-1166-0-18507800-1441472175_thumb.pn

Share this post


Link to post
Share on other sites

Ok I got it to work.

I realised I had to zap the contents of both 'item_tpl' and item_current_tpl' 

My final working code is as follows.

Apologies if I'm filling up this thread with my own hacked code and examples. Just hoping it's useful to someone in the future.

<?php 

$nav = $modules->get("MarkupSimpleNavigation");

function myItemString(HookEvent $event){
    $child = $event->arguments('page'); // current rendered child page
    // any logic with $child possible here
    	
		$myimage = $child->nav_icon;
        // set the return value of this hook to a custom string
        $event->return .= "<div class='nav-icon'><img src='{$myimage->url}'></div><a href='$child->url'>$child->title</a>";
   
}


$options = array(
				'parent_class' => 'parents',
				'current_class' => 'current',
				'has_children_class' => 'has_children',
				'levels' => true,
				'levels_prefix' => 'level-',
				'max_levels' => 1,
				'firstlast' => true,
				'collapsed' => false,
				'show_root' => true,
				'selector' => '',
				'selector_field' => 'nav_selector',
				'outer_tpl' => '<ul class="sidelist">||</ul>',
				'inner_tpl' => '<ul>||</ul>',
				'list_tpl' => '<li%s >||</li>',
				'list_field_class' => '',
				'item_tpl' => '',
				'item_current_tpl' => '',
				'xtemplates' => '',
				'xitem_tpl' => '<a href="{url}">{title}</a>',
				'xitem_current_tpl' => '<span>{title}</span>',
				'date_format' => 'Y/m/d',
				'code_formatting' => false,
				'debug' => false
			);
$root = $page->rootParent; // Start from the top root parent of current page
// setup the hook after on ___getItemString($class, $page) method
$nav->addHookAfter('getItemString', null, 'myItemString');
echo $nav->render($options, null, $root);

?>

Share this post


Link to post
Share on other sites

Sorry little late at the party but like i wrote a little how to use MSN for a megamenu or add any other items between items...

this should be the result - some li item with extra div content with latest/top article and some other items in this example from a pagefield/categories....

post-2327-0-50642100-1441473527_thumb.pn

Code ist hopefully well commented...

//topMenuNav
$rootPage = $page->get('/'); //shows current tree
$topMenu = $modules->get("MarkupSimpleNavigation"); // load the module

// hook to have custom items markup
$topMenu->addHookAfter('getTagsString', null, 'customNavItems');

function customNavItems(HookEvent $event){
    $item = $event->arguments('page');
    // get the article mainnav item and add some megamenu items...
    if($item->id == 1068){

        //build the normal li item output
        $out    = '<a href="'.$item->get("url").'">'.$item->get("title|name").'</a>';

        //get the last article
        $top_article = wire('pages')->find("template=artikel,top_thema=1,sort=-publish_from")->first();
        //get the last article
        $latest_article = wire('pages')->find("template=artikel,sort=-publish_from")->first();

        //get image thumb from $top_article
        //get the original image
        $imagetop = $top_article->get("artikel_bild");
        // get the image instance of the cropped version of "artikel" 750px wide
        $thumbtop = $top_article->artikel_bild->getCrop('Artikel');

        //get image thumb from $latest_article
        //get the original image
        $imagelatest = $latest_article->get("artikel_bild");
        // get the image instance of the cropped version of "artikel" 750px wide
        $thumblatest = $latest_article->artikel_bild->getCrop('Artikel');

        //get the items for the tagmenu
        $cat_items = wire('pages')->find("template=artikel_cat");

        //get the rootpage of the posts
        $artikel_root = wire('pages')->get(1068);
        //homepageurl
        $homepageurl = wire('pages')->get('/')->httpUrl;

        //start megamenu
        $out    .= '<ul class="mega">';
        //first column last "top" marked article
        $out    .= '<div class="one_third"><h4 class="subtitle">Top Aktuell</h4>';
        $out        .= '<a class="mega-link-img" href="'.$top_article->get("url").'"><img src="'.$thumbtop->url.'" alt="'.$thumbtop->description.'"><br></a>';
        $out        .= '<h6><strong>'.$top_article->get("headline").'</strong></h6>';
        $out        .= '<p>'.$top_article->get("shorttext").'</p>';
        $out    .= '</div>';
        //second column - latest article
        $out    .= '<div class="one_third"><h4 class="subtitle">Letzter Artikel</h4>';
        $out        .= '<a class="mega-link-img" href="'.$latest_article->get("url").'"><img src="'.$thumblatest->url.'" alt="'.$thumblatest->description.'"><br></a>';
        $out        .= '<h6><strong>'.$latest_article->get("headline").'</strong></h6>';
        $out        .= '<p>'.$latest_article->get("shorttext").'</p>';
        $out    .= '</div>';
        //third column - list of tags (links to URL segments on artikel_stamm template)
        $out    .= '<div class="one_third"><h4 class="subtitle">Themenbereiche</h4>';
            foreach ($cat_items as $cat) {
                $out .= '<li><a href="'.$homepageurl.$artikel_root->name.'/'.$cat->name.'/">'.$cat->title.'</a></li>';
            }
        $out    .= '</div>';
        //close megamenu
        $out    .= '</ul>';
        $event->return = $out;
    }
}

$options = array(
    'parent_class' => 'parent',        // overwrite class name for current parent levels
    'current_class' => 'current',    // overwrite current class
    'has_children_class' => 'has_children',    // overwrite class name for entries with children
    'levels' => true,    // wether to output "level-1, level-2, ..." as css class in links
    'levels_prefix' => '',    // prefix string that will be used for level class
    'max_levels' => 3,    // set the max level rendered
    'firstlast' => false,    // puts last,first class to link items
    'collapsed' => false,    // if you want to auto-collapse the tree you set this to true
    'show_root' => false,    // set this to true if you want to rootPage to get prepended to the menu
    'selector' => 'template!=artikel|event',    // define custom PW selector, you may sanitize values from user input
    'selector_field' => 'nav_selector',    // string (default 'nav_selector') define custom PW selector by using a property or field on a page. Use this setting if you want to overwrite the default nav_selector
    'outer_tpl' => '<ul id="nav" class="sixteen columns">||</ul>',    // template string for the outer most wrapper. || will contain entries
    'inner_tpl' => '<ul>||</ul>',    // template string for inner wrappers. || will contain entries
    //'list_tpl' => '',    // template string for the items. || will contain entries, %s will replaced with class="..." string
    'list_field_class' => '',  // string (default '') add custom classes to each list_tpl using tags like {field} i.e. {template} p_{id}
    'item_tpl' => '<a href="{url}">{title}</a>',    // template string for the inner items. Use {anyfield} and {url}, i.e. {headline|title}, if field is of type image it will return url to image (first image if multiple)
    'item_current_tpl' => '<a href="{url}">{title}</a>',    // template string for the active inner items.
    'xtemplates' => '',    // specify one or more templates separated with a pipe | to use the xitem_tpl and xitem_current_tpl markup
    'xitem_tpl' => '',    // same as 'item_tpl' but for xtemplates pages, can be used to define placholders
    'xitem_current_tpl' => '',    // same as 'item_current_tpl' but for xtemplates pages
    'date_format' => 'Y/m/d',    // default date formatting for Datetime fields and native created/modified
    'code_formatting' => true,    // enable or disable code indentations and newslines in markup output
    'debug' => false,    // show some inline information about rendertime and selectors used as html comments
);

$topMenuMarkup = $topMenu->render($options, null, $rootPage);

It's long and detailed i always like to see how all options of the Menu are set....so options could be less.

Hope this works for others as example how to get there with MarkupSimpleNavigation...on such topics.

I like this module very much since in my former CMS there was a great function for generating menus, too. With this kind of generating markup for navigation it is not always easy but it is always very powerfull and if you've it running it a solid solution ;)

Best regards mr-fan

  • Like 2

Share this post


Link to post
Share on other sites

Hello, 

how to hook the Module right. 

I need for an document e.g id = 1033 to target blank my custom url. 

Which is the best way to realize that ? 

Tnx 

Share this post


Link to post
Share on other sites

if you take my example from above you could strip it to the minimal setup like this:

//topMenuNav
$rootPage = $page->get('/'); //shows current tree
$topMenu = $modules->get("MarkupSimpleNavigation"); // load the module

// hook to have custom items markup
$topMenu->addHookAfter('getTagsString', null, 'customNavItems');

function customNavItems(HookEvent $event){
    $item = $event->arguments('page');

    //if the item id is 1068 do something

    if($item->id == 1068){

        //build the normal li item output or change the item with id 1068 to your needs
        //add new items that aren't in the normal pagetree or add megamenu items
        //....do what you want!
        
        $out    = '<a href="'.$item->get("url").'">'.$item->get("title|name").'</a>';

        $event->return = $out;
    }
}
//setup $options for the normal markup and render the nav...

so you could get every special item you need and change it.

best regards mr-fan

  • Like 1

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 Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-07-03 -- SnipWire 0.8.7 (beta) released! Fixes some small bugs and adds an indicator for TEST mode 2020-04-06 -- SnipWire 0.8.6 (beta) released! Adds support for Snipcart subscriptions and also fixes some problems 2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  

       
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By Sten
      Hello
      Till now I hacked something with the twig template but it works no more with new PW versions so I look forward to create a module. I am working on a site in multiple languages : French, English, Italian, German, Spanish, Portuguese, Hebrew, Russian. The new posts are entered in any language with a field for language. Till now, I got twig files to get the translations with constants defined for each part of the pages.
      So I'd like to create a module to include theses files added according to the url /fr/en/...
      Have you some observations to do before I begin about the direction to take ?
      Thank you
    • By ukyo
      Mystique Module for ProcessWire CMS/CMF
      Github repo : https://github.com/trk/Mystique
      Mystique module allow you to create dynamic fields and store dynamic fields data on database by using a config file.
      Requirements
      ProcessWire 3.0 or newer PHP 7.0 or newer FieldtypeMystique InputfieldMystique Installation
      Install the module from the modules directory:
      Via Composer:
      composer require trk/mystique Via git clone:
      cd your-processwire-project-folder/ cd site/modules/ git clone https://github.com/trk/Mystique.git Module in live reaction with your Mystique config file
      This mean if you remove a field from your config file, field will be removed from edit screen. As you see on youtube video.
      Using Mystique with your module or use different configs path, autoload need to be true for modules
      Default configs path is site/templates/configs/, and your config file name need to start with Mystique. and need to end with .php extension.
      Adding custom path not supporting anymore !
      // Add your custom path inside your module class`init` function, didn't tested outside public function init() { $path = __DIR__ . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR; Mystique::add($path); } Mystique module will search site/modules/**/configs/Mystique.*.php and site/templates/Mystique.*.php paths for Mystique config files.
      All config files need to return a PHP ARRAY like examples.
      Usage almost same with ProcessWire Inputfield Api, only difference is set and showIf usage like on example.
      <?php namespace ProcessWire; /** * Resource : testing-mystique */ return [ 'title' => __('Testing Mystique'), 'fields' => [ 'text_field' => [ 'label' => __('You can use short named types'), 'description' => __('In file showIf working like example'), 'notes' => __('Also you can use $input->set() method'), 'type' => 'text', 'showIf' => [ 'another_text' => "=''" ], 'set' => [ 'showCount' => InputfieldText::showCountChars, 'maxlength' => 255 ], 'attr' => [ 'attr-foo' => 'bar', 'attr-bar' => 'foo' ] ], 'another_text' => [ 'label' => __('Another text field (default type is text)') ] ] ]; Example:
      site/templates/configs/Mystique.seo-fields.php <?php namespace ProcessWire; /** * Resource : seo-fields */ return [ 'title' => __('Seo fields'), 'fields' => [ 'window_title' => [ 'label' => __('Window title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'attr' => [ 'placeholder' => __('Enter a window title') ] ], 'navigation_title' => [ 'label' => __('Navigation title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'showIf' => [ 'window_title' => "!=''" ], 'attr' => [ 'placeholder' => __('Enter a navigation title') ] ], 'description' => [ 'label' => __('Description for search engines'), 'type' => Mystique::TEXTAREA, 'useLanguages' => true ], 'page_tpye' => [ 'label' => __('Type'), 'type' => Mystique::SELECT, 'options' => [ 'basic' => __('Basic page'), 'gallery' => __('Gallery'), 'blog' => __('Blog') ] ], 'show_on_nav' => [ 'label' => __('Display this page on navigation'), 'type' => Mystique::CHECKBOX ] ] ]; Searching data on Mystique field is limited. Because, Mystique saving data to database in json format. When you make search for Mystique field, operator not important. Operator will be changed with %= operator.
      Search example
      $navigationPages = pages()->find('my_mystique_field.show_on_nav=1'); $navigationPages = pages()->find('my_mystique_field.page_tpye=gallery');
    • By Robin S
      This is a module I made as an experiment a while ago and never got around to releasing publicly. At the time it was prompted by discussions around using Repeater fields for "page builder" purposes, where the depth feature could possibly be used for elements that would be nested inside other elements. I thought it would be useful to enforce some depth rules and translate the depth data into a multi-dimensional array structure.
      I'm not using this module anywhere myself but maybe it's useful to somebody.
      Repeater Depth Helper
      This module does two things relating to Repeater fields that have the "Item depth" option enabled:
      It enforces some depth rules for Repeater fields on save. Those rules are:
      The first item must have a depth of zero. Each item depth must not be more than one greater than previous item depth. It provides a RepeaterPageArray::getDepthStructure helper method that returns a nested depth structure for a Repeater field value.
      Helper method
      The module adds a RepeaterPageArray::getDepthStructure method that returns a multi-dimensional array where the key is the page ID and the value is an array of nested "child" items, or null if there are no nested children.
      Example

      The module doesn't make any assumptions about how you might want to use the depth structure array, but here is a way you might use it to output a nested unordered list.
      // Output a nested unordered list from a depth structure array function outputNestedList($depth_structure, $repeater_items) { $out = "<ul>"; foreach($depth_structure as $page_id => $nested_children) { $out .= "<li>" . $repeater_items->get("id=$page_id")->title; // Go recursive if there are nested children if(is_array($nested_children)) $out .= outputNestedList($nested_children, $repeater_items); $out .= "</li>"; } $out .= "</ul>"; return $out; } $repeater_items = $page->my_repeater; $depth_structure = $repeater_items->getDepthStructure(); echo outputNestedList($depth_structure, $repeater_items);
       
      https://github.com/Toutouwai/RepeaterDepthHelper
      https://modules.processwire.com/modules/repeater-depth-helper/
    • 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 If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
×
×
  • Create New...