Jump to content

MarkupSimpleNavigation


Soma

Recommended Posts

Next little tutorial on this really great module...

Getting a Footermenu stripped from the mainmenu and output in a footermenu

1. Setup Pagefield for your /settings/ or /tools/ page

This solution could be set by the user direct via a simple pagefield to select normal contentpages that a normaly in the mainmenu...but this items should stay not there and render somewhere else...

post-2327-0-42569000-1442412709_thumb.jp

2. Strip the choosen pages from the mainmenu

//get the pagefield content
$footerMenu = $settings->footer_menu;

//just the needed option listed - other options like needed for your menu
$options = array(
       'selector' => 'id!='.$footerMenu.'',    // define custom PW selector
);

3. Output the pagefield items

post-2327-0-41513000-1442412792_thumb.jp

<?php //in my example i am in the _main.php template and render some footermenu
if ($settings->footer_menu) { //check for the pagefield
    echo '<div class="eight columns">';
    foreach ($settings->footer_menu as $item) {
        if (!$item->is('hidden') || $item->is('unpublished')) { //check for hidden/unpublished pages!!
	    echo '<a href="'.$item->url.'" class="button sendbtn btnSend">'.$item->title.'</a>';
	}
    }
    echo '</div>';
}
?>

hope this is helpful...have fun.

I don't have a blog and i am a fan of keeping things together....so don't bother if i'm posting such things here and write me if such usecases are not helpful or nonsense...... ;)

Best regards mr-fan

  • Like 2
Link to comment
Share on other sites

Is it possible to use the "selector" option to choose menu items based on parent?

I tried...

"selector" => "parent=1020"

...and...

"selector" => "parent=/my-page/"

...but neither of these worked.

I know I can do this by setting a PageArray as the root object but I'm trying to understand why I can't do this with the selector option.

Link to comment
Share on other sites

No it's not possible, it iterates the tree structure as is. "parent -> childrens -> childrens".

You can only set the top root items per a PageArray. Form there these are iterated down the tree. The selector only is used to filter the children of the current nodes.

Link to comment
Share on other sites

Next little tutorial on this really great module...

Getting a Footermenu stripped from the mainmenu and output in a footermenu

1. Setup Pagefield for your /settings/ or /tools/ page

This solution could be set by the user direct via a simple pagefield to select normal contentpages that a normaly in the mainmenu...but this items should stay not there and render somewhere else...

attachicon.giffootermenu.jpg

2. Strip the choosen pages from the mainmenu

//get the pagefield content
$footerMenu = $settings->footer_menu;

//just the needed option listed - other options like needed for your menu
$options = array(
       'selector' => 'id!='.$footerMenu.'',    // define custom PW selector
);

3. Output the pagefield items

attachicon.giffootermenusorting.jpg

<?php //in my example i am in the _main.php template and render some footermenu
if ($settings->footer_menu) { //check for the pagefield
    echo '<div class="eight columns">';
    foreach ($settings->footer_menu as $item) {
        if (!$item->is('hidden') || $item->is('unpublished')) { //check for hidden/unpublished pages!!
	    echo '<a href="'.$item->url.'" class="button sendbtn btnSend">'.$item->title.'</a>';
	}
    }
    echo '</div>';
}
?>

hope this is helpful...have fun.

I don't have a blog and i am a fan of keeping things together....so don't bother if i'm posting such things here and write me if such usecases are not helpful or nonsense...... ;)

Best regards mr-fan

There's a tutorial board here in the forums where you would post such examples. I don't think it helps much in here.

Link to comment
Share on other sites

There's a tutorial board here in the forums where you would post such examples. I don't think it helps much in here.

Ok if i've the time i collect my snippets to a "Tipps&Tricks with MarkupSimpleNavigation" topic - to get things connected.

For myself - i always read modulethreat completly if i'm using them to get the best start or knowlegde about the used addon...Read the fucking Manual....is not a option it is a obligation if you are new to a cms/module/technique....;)

But i will follow your advice since it better fits as tutorials than tracking issues or getting help.

Best regards and thank you for feedback mr-fan

Link to comment
Share on other sites

  • 1 month later...

Markup Simple Navigation Module

While there was a lot of people asking how to make navigation, and there were many examples around already (apeisa, ryan...) I took the chance to sit down 2-3 hours to make a simple navigation module. It has even some options you can control some aspects of the output.

Installation:

1. Put this module's folder "MarkupSimpleNavigation" into your /site/modules folder.

2. Go to your module Install page and click "Check for new modules". It will appear under the section Markup. Click "install" button. Done.

Technically you don't even need to install it, after the first load call ( $modules->get("MarkupSimpleNavigation") ) it will install automaticly on first request if it isn't already. But it feels better. However, it will not be "autoloaded" by Processwire unless you load it in one of your php templates.

Documentation:

https://github.com/somatonic/MarkupSimpleNavigation/blob/master/README.md

Modules Repository processwire.com

mods.pw/u

Download on github

https://github.com/somatonic/MarkupSimpleNavigation

Advanced example with hooks

creating a Bootstrap 2.3.2 Multilevel Navbar

https://gist.github.com/somatonic/6258081

I use hooks to manipulate certain attributes and classes to li's and anchors. If you understand the concept you can do a lot with this Module.

could i put the "creating a Bootstrap 2.3.2 Multilevel Navbar" code in the _init.php to run ?

Link to comment
Share on other sites

Hi Soma,

I need to use plain PHP pages ("/foo/bar.php") to a website powered by ProcessWire. How can I add this in Markup Simple Navigation?

Sample structure that shows the mix of Processwire pages and PHP pages in use:

  • Products
    • Product 1
    • Product 2
    • Product 3
    • Request quote <- Quote form in plain PHP.
  • References
  • About us
Link to comment
Share on other sites

Wanted to ask the same.

Only way I see is use a page with a text field to enter a path to a php file. Then use that field as in the url tag in the item template. I.e. href='{pathphp|url}'

Link to comment
Share on other sites

@Mike Rockett & Soma: The reason for processing the form outside PW is that it's part of a 3rd party booking system using an external database.

I have the following enhancement request for the module: "It shall be possible to include plain PHP pages ("/foo/bar.php") from third party plug-ins and the like to MarkupSimpleNavigation. Suggested solution is to allow adding in-memory pages to the navigation entries on the fly. The purpose of adding in-memory pages is to place the 3rd party page in PWs Page structure. Something along these lines:

$p = new Page();
$p->setOutputFormatting(false);
$p->parent = $pages->get("/MyParentPage");
$p->template = "SomeTemplate";
$p->title = "External page";
$p->name = "external_page";
// Note I do not use $p->save(), so it's a pseudo page that exists in memory only.
// Add the page to $entries somehow [...] -> $entries = $pages->get("/")->navigation_entries; ....
$entries = $pages->get("/")->navigation_entries; // Load entries (including our new page)
echo $treeMenu->render(null, null, $entries);

(Perhaps this is already possible without making changes to the module?)

Right now, I will go ahead and 1) make a unique template for the form that "include()" the form from a PHP file, 2) add a PW page for the form and 3) repeat this process for all relevant files (4 times in total per site using the booking system). I can then output a link and title to the page using MarkupSimpleNavigation. (I have done this before, it's a bit cumbersome but it will work.)

Link to comment
Share on other sites

While it would be possible to inject in memory pages, I don't want to go that route for various reasons.

What I do is add a dummy page as you mention. Then add a field "exturl" to the template. Then enter the url in that field like "/path/to/file.php".

In the navigation code you then use "exturl" in the item_tpl:

$options = array("item_tpl" => "<a href='{exturl|url}>{title}</a>');
  • Like 1
Link to comment
Share on other sites

  • 1 month later...

I have problems with outputting the whole Menu Tree  up to the parent page Product when in 3rd level of a submenu.

The structure is

Home

  Products

      product 1

      product 2

         Item 1

         Item 2

         Item 4

      product 3

My menu looks like this

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

$leftNavOptions = array(
	'max_levels' => 3,
	'collapsed' => true,
	'show_root' => false,
	'levels' => true,
	'outer_tpl' => '<ul id="leftNavOuter" class="noPrint">||</ul>',
	'firstlast' => true
);

$root = $page->parents->count == 1 ? $page : $page->parent;
echo $leftNav->render($leftNavOptions, $page, $root);

that works perfect well until you navigate into the 3rd Level, then all levels above disapear and you see only the items level

Is there a way to output all three levels when in 3rd level?

Your help is much appreciated.

Link to comment
Share on other sites

that works perfect well until you navigate into the 3rd Level, then all levels above disapear and you see only the items level

I think your problem comes from this:

$root = $page->parents->count == 1 ? $page : $page->parent;

For the first two levels $root is "Products", but on the third level $root is "product 2" or whatever level 2 parent you are in. So you only see children of "product 2".

I think this will do what you want:

$root = $page->rootParent;
Link to comment
Share on other sites

  • 2 weeks later...

Hello all,

I have two questions:

First:

using MSN Module ... is it possible to have "unlinked" items  in the menu?.
I have several pages that serve as headlines to structure the content better. They have a seprate template (menu-ueberschrift) and they should not be clickable ... just be there as plain text. These Items have children. I want an uncollapsed menu..

Second question:

Goes into the same direction: I would like to have active pages without links, too. I think there is no need for links  for a page I'm currently viewing.

Hopefully someone can help, as I'm stuck here.

Link to comment
Share on other sites

Solved it myself ...

Finally managed to set up hooks:

function myItemString(HookEvent $event) {
    $child = $event->arguments('page'); // current rendered child page
    // any logic with $child possible here
    
    /**
     * Überschriften
     */
    if ($child->template->name == 'menue-ueberschrift') {
        $event->return = "<span> $child->title</span>";
    };

    /**
     * active
     */
    if ($child->template->name == 'standard') {
        if ($child->id == wire('page')->id) {
            $event->return = "<span> $child->title</span>";

        }
    };
}

// setup the hook after on ___getItemString($class, $page) method
$nav->addHookAfter('getItemString', null, 'myItemString');
/* Render Navigation Markup adding options, too---------------- */
echo $nav->render()

Seems to work so I guess it's ok.

And I've learned something new :-)

Cheers Hanna

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Ok,

I am having some issues with this menu (will be in bootstrap).

I currently have:

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

	 function hookGetListClass(HookEvent $event){
	    $child = $event->arguments('page'); // current rendered child page
	    $class = $event->arguments('class'); // the class string already present
			$options = array(
				'has_children_class' => 'dropdown',
				'outer_tpl' => '<ul class="nav">||</ul>',
				'inner_tpl' => '<ul class="dropdown-menu">||</ul>'
			);


	     // any check on that child to set your custom class
	     if($child->id == 1001){
	         $event->return .= " inner"; // add your custom class to the existing
	     }
	 }

	 // setup the hook after on ___getListClass($class, $page) method
	 $nav->addHookAfter('getListClass', null, 'hookGetListClass');
	 echo $nav->render($options);
	 ?>

However, the nav doesnt seem to be taking the options, and is instead using the "has_children" class. I saw a post almost exactly like this, but couldnt get the outcome. The inner ul should have a class of "dropdown".

Link to comment
Share on other sites

Hey guys,

I love this plugin. It works almost perfect for me. But I have a little question. I want that the parents don´t have a link.

This is my markup now:
<nav>
               
        <a href="<?=$config->urls->root; ?>" id="home">Von der Berkelaue</a>
       
        <?php 
            $treeMenu = $modules->get("MarkupSimpleNavigation"); // Modul laden   

        
            $options = array(
                'max_levels' => 2,
                'show_root' => true,
                'outer_tpl' => '<ul id="menu">||</ul>',
                'inner_tpl' => '<ul>||</ul>',
                'list_tpl' => '<li%s>||</li>',
                'item_tpl' => '<a href="{url}">{title}</a>',
                'item_current_tpl' => '<a href="{url}" class="active">{title}</a>',
                'debug' => true,
                'selector' => 'template!=aktuelles-eintrag, has_parent!=/galerie/',
            );
            echo $treeMenu->render($options); // Navigation rendern
        ?>
    </nav>

And this is my output:

<ul id="menu">
    <li class="current"><a href="/" class="active">Startseite</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li><a href="/aktuelles/">Aktuelles</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li class="has_children"><a href="/uber-uns/">Über uns</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
        <ul>
            <li><a href="/uber-uns/familie/">Familie</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/uber-uns/unsere-hunde/">Unsere Landseer</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
        </ul>
    </li>
    <li><a href="/wurfplanung/">Wurfplanung</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li class="has_children"><a href="/wurfe/">Würfe</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
        <ul>
            <li><a href="/wurfe/wurfplanung/">A-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/b-wurf/">B-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/c-wurf/">C-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/d-wurf/">D-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/e-wurf/">E-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/f-wurf/">F-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/g-wurf/">G-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
        </ul>
    </li>
    <li><a href="/galerie/">Galerie</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li><a href="/gastebuch/">Gästebuch</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li><a href="/links/">Links</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li><a href="/kontakt/">Kontakt</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
</ul>
<!-- [MarkupSimpleNavigation Rendertime: 0.0366] -->
</nav>

And it should look like this:

<ul id="menu">
    <li class="current"><a href="/" class="active">Startseite</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li><a href="/aktuelles/">Aktuelles</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li class="has_children"><a href="#">Über uns</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
        <ul>
            <li><a href="/uber-uns/familie/">Familie</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/uber-uns/unsere-hunde/">Unsere Landseer</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
        </ul>
    </li>
    <li><a href="/wurfplanung/">Wurfplanung</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li class="has_children"><a href="#">Würfe</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
        <ul>
            <li><a href="/wurfe/wurfplanung/">A-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/b-wurf/">B-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/c-wurf/">C-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/d-wurf/">D-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/e-wurf/">E-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/f-wurf/">F-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
            <li><a href="/wurfe/g-wurf/">G-Wurf</a>
                <!-- [Selector Level2: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
            </li>
        </ul>
    </li>
    <li><a href="/galerie/">Galerie</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li><a href="/gastebuch/">Gästebuch</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li><a href="/links/">Links</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
    <li><a href="/kontakt/">Kontakt</a>
        <!-- [Selector Level1: template!=aktuelles-eintrag, has_parent!=/galerie/] -->
    </li>
</ul>
<!-- [MarkupSimpleNavigation Rendertime: 0.0366] -->
</nav>

I hope you understand my problem. My english isn´t very good :D

Thanks, Jannis

Link to comment
Share on other sites

Hi Jannis,

Is  that you want this

<li class="has_children"><a href="#">Über uns</a>

appear like a headline ? with no link?

I think it would be a good idea to give those 'headlines' their own template like 'ueberschrift' or so.

Then you could proceed similar to what I posted here using a hook.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi,

i am using this Module for quit a while with great joy. Easy to implement and very flexible.

Right now i wonder if something like this is possible by using just the module options without hooking the core: I have a 2-level menu with several parents and relevant child pages. On last parent the child array is (should) populated from a variable ($items), which collects only (child) pages with dedicated page view permission.

So i fiddle around with the "selector_levelN" option. First try:

$options = array(
  "levels" => true,
  "max_levels" => 2,
  "selector_level2" => "id=$items"
);

This gives me the expected result in level2 on the last child tree, but fails of course because the selector ("id="$items") returns nothing on all other parent/child levels. What i would need is some condition like (Tried this and other notations, no luck):

$options = array(
...
"selector_level2" => (parent=<id>) ? "id=$items" : ""
);

In words. If the parent page has a dedicated ID (here: the parent page which holds all permission controlled (child) pages), populate the "selector_level2" option with predefined pages ($items), otherwise don't constrain the collecting for level 2.

Probably this is the nutshell: Are condition possible/allowed in module option selector values?

cheers and thanks

felic

Link to comment
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 monollonom
      PageMjmlToHtml
      Github: https://github.com/romaincazier/PageMjmlToHtml
      Modules directory: https://processwire.com/modules/page-mjml-to-html/ (pending approval)
      A module allowing you to write your Processwire template using MJML and get a converted HTML output using MJML API.
      This is considered to be in alpha and as such needs some testing before being used in production!

      About
      Created by Mailjet, MJML is a markup language making it a breeze to create newsletters displayed consistently across all email clients.
      Write your template using MJML combined with Processwire’s API and this module will automatically convert your code into a working newsletter thanks to their free-to-use Rest API.
      Prerequisite
      For this module to work you will need to get an API key and paste it in the module’s configuration.
      Usage
      Once your credentials are validated, select the template(s) in which you’re using the MJML syntax, save and go visualize your page(s) to see if everything’s good. You will either get error/warning messages or your email properly formatted and ready-to-go.
      From there you can copy/paste the raw generated code in an external mailing service or distribute your newsletter using ProMailer.
      Features
      The MJML output is cached to avoid repetitive API calls Not cached if there are errors/warnings Cleared if the page is saved Cleared if the template file has been modified A simple (dumb?) code viewer highlights lines with errors/warnings A button is added to quickly copy the raw code of the generated newsletter Not added if the page is rendered outside of a PageView Only visible to users with the page’s edit permission A shortcut is also added under “View” in the edit page to open the raw code in a new tab Multi-languages support
      Notes
      The code viewer is only shown to superusers. If there’s an error the page will display:
      Only its title for guests Its title and a message inviting to contact the administrator for editors If you are using the markup regions output strategy, it might be best to not append files to preserve your MJML markup before calling the MJML API. This option is available in the module’s settings.
    • By Marco Ro
      Hi guys!
      I'm a bit anxious because this is the first module I present! (beta modulo) But I will finally be able to share something with the community too! :)
      This is a BETA version of the PayPal payment system called: PayPal Commerce Platform.
      It is an advanced system (Business Pro account is needed) that brings various benefits in terms of fees and above all integrates direct payment with credit/debit cards. 
      The module integrates with Padloper 0.0.2, which is the current installation I'm using.
      This system integrates the classic PayPal buy button, the alternative or local payment method and the new payment system: credit/debit cards that doesn't go through the PayPal account. It is a Stripe-style payment, it connects directly with the bank and integrates 3D security validation.
      I say that it is a BETA because this module currently only works with Sandbox account, to put it live you need to change API url manually (manually for the moment).
      Because this module is not ready for live:
      I would like to have your opinion on how I built the module (is the first one I do). I don't want to share something that is not fish but I need a comparison with someone more experienced than me, for be sure that this is the best way to code the module.
      If you want to try this I created a git, you will find all the instructions for installation and correct operation. (Git has a MIT licensed)
      https://github.com/MarcooRo/processwire-PayPal-Commerce-Platform I hope I did something that you guys can like :)
    • By monollonom
      (once again I was surprised to see a work of mine pop up in the newsletter, this time without even listing the module on PW modules website 😅. Thx @teppo !)
      FieldtypeQRCode
      Github: https://github.com/romaincazier/FieldtypeQRCode
      Modules directory: https://processwire.com/modules/fieldtype-qrcode/
      A simple fieldtype generating a QR Code from the public URL of the page, and more.
      Using the PHP library QR Code Generator by Kazuhiko Arase.

      Options
      In the field’s Details tab you can change between .gif or .svg formats. If you select .svg you will have the option to directly output the markup instead of a base64 image. SVG is the default.
      You can also change what is used to generate the QR code and even have several sources. The accepted sources (separated by a comma) are: httpUrl, editUrl, or the name of any text/URL/file/image field.
      If LanguageSupport is installed the compatible sources (httpUrl, text field, ...) will return as many QR codes as there are languages. Note however that when outputting on the front-end, only the languages visible to the user will be generated.
      Formatting
      Unformatted value
      When using $page->getUnformatted("qrcode_field") it returns an array with the following structure:
      [ [ "label" => string, // label used in the admin "qr" => string, // the qrcode image "source" => string, // the source, as defined in the configuration "text" => string // and the text used to generate the qrcode ], ... ] Formatted value
      The formatted value is an <img>/<svg> (or several right next to each other). There is no other markup.
      Should you need the same markup as in the admin you could use:
      $field = $fields->get("qrcode_field"); $field->type->markupValue($page, $field, $page->getUnformatted("qrcode_field")); But it’s a bit cumbersome, plus you need to import the FieldtypeQRCode's css/js. Best is to make your own markup using the unformatted value.
      Static QR code generator
      You can call FieldtypeQRCode::generateQRCode to generate any QR code you want. Its arguments are:
      string $text bool $svg Generate the QR code as svg instead of gif ? (default=true) bool $markup If svg, output its markup instead of a base64 ? (default=false) Hooks
      Please have a look at the source code for more details about the hookable functions.
      Examples
      $wire->addHookAfter("FieldtypeQRCode::getQRText", function($event) { $page = $event->arguments("page"); $event->return = $page->title; // or could be: $event->return = "Your custom text"; }) $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function($event) { $qrcodes = $event->return; // keep everything except the QR codes generated from editUrl foreach($qrcodes as $key => &$qrcode) { if($qrcode["source"] === "editUrl") { unset($qrcodes[$key]); } } unset($qrcode); $event->return = $qrcodes; })
    • By Sebi
      AppApiFile adds the /file endpoint to the AppApi routes definition. Makes it possible to query files via the api. 
      This module relies on the base module AppApi, which must be installed before AppApiFile can do its work.
      Features
      You can access all files that are uploaded at any ProcessWire page. Call api/file/route/in/pagetree?file=test.jpg to access a page via its route in the page tree. Alternatively you can call api/file/4242?file=test.jpg (e.g.,) to access a page by its id. The module will make sure that the page is accessible by the active user.
      The GET-param "file" defines the basename of the file which you want to get.
      The following GET-params (optional) can be used to manipulate an image:
      width height maxwidth maxheight cropX cropY Use GET-Param format=base64 to receive the file in base64 format.
    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
×
×
  • Create New...