Jump to content
kongondo

Menu Builder

Recommended Posts

how can I assign a classe to the a TAG in the menu?

have just reviewed docu and Github but find nothing

Share this post


Link to post
Share on other sites
17 hours ago, MateThemes said:

How can I close the <div class="uk-navbar-dropdown">? Everything I've tried seems not to work!

Try this one:

Please note that the \t and \n need cleaning up.

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 .= "\n<ul class='uk-navbar-nav'>";
							$first = 1;
						}
						else {
							$out .=
								"\n\t<div class='uk-navbar-dropdown'>" .
									"\n\t\t<ul class='uk-nav uk-navbar-dropdown-nav'>";
						}
				}
				// active/current menu item
				$class = $m->isCurrent ? ' class="uk-active"' : '';

				// a menu item
				$out .= "\n\t<li$class><a href='{$m->url}{$newtab}'>{$m->title}</a>";

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

		}// end if parent

	}// end foreach

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

	return $out;

}

// example usage
                              
$mb = $modules->get('MarkupMenuBuilder');
$menuItemsAsObject = $mb->getMenuItems(1041, 2);
$menu = "\n<div class='uk-navbar-center uk-visible@m'>";
$menu .= buildMenuFromObject(0, $menuItemsAsObject);
$menu .= "</div>\n";

echo $menu;

 

  • Like 1

Share this post


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

Try this one:

Please note that the \t and \n need cleaning up.


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 .= "\n<ul class='uk-navbar-nav'>";
							$first = 1;
						}
						else {
							$out .=
								"\n\t<div class='uk-navbar-dropdown'>" .
									"\n\t\t<ul class='uk-nav uk-navbar-dropdown-nav'>";
						}
				}
				// active/current menu item
				$class = $m->isCurrent ? ' class="uk-active"' : '';

				// a menu item
				$out .= "\n\t<li$class><a href='{$m->url}{$newtab}'>{$m->title}</a>";

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

		}// end if parent

	}// end foreach

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

	return $out;

}

// example usage
                              
$mb = $modules->get('MarkupMenuBuilder');
$menuItemsAsObject = $mb->getMenuItems(1041, 2);
$menu = "\n<div class='uk-navbar-center uk-visible@m'>";
$menu .= buildMenuFromObject(0, $menuItemsAsObject);
$menu .= "</div>\n";

echo $menu;

 

Thank you very much!!! This works great!!!

Share this post


Link to post
Share on other sites
17 hours ago, csaeum said:

how can I assign a classe to the a TAG in the menu?

You cannot unless

a. You use <a> as the list_type

OR

b. You use getMenuItems() with custom menu generator. See most recent example above and this post for more information about complex menus.

Share this post


Link to post
Share on other sites

Good day @kongondo and everyone here!

I am trying to get my menus with MenuBuilder to work, but having some strange issue.

This is my code:

<?php namespace ProcessWire;

$menuBuilder = $modules->get('MarkupMenuBuilder');
$mainMenuLeft = $menuBuilder->getMenuItems('main-menu-left');
bd($mainMenuLeft, '$mainMenuLeft');

And this is a screen of MenuBuilder admin page:

MB.png.fe6d855303423b126109462901e0199e.png

The problem is I get 0 items. And only if I add the homepage I get 1 (and this is the homepage).

Either I am doing something wrong or something got broken) Please help me!

Share this post


Link to post
Share on other sites
1 hour ago, Ivan Gretsky said:

Either I am doing something wrong or something got broken) Please help me!

If the pages are not viewable they won't appear in the menu/won't be returned as menu items. Make sure the templates they use have a template file and there aren't any other restrictions.

  • Like 3

Share this post


Link to post
Share on other sites

Update: Menu Builder Version 0.2.5.

Just a quick maintenance update.

Changelog

  1. Fixed a minor bug where we had to check if a variable was an array first before "counting" it.
  2. Removed a leftover debugging statement from the code (an echo of all things! Not even a bd()!!) 😁.
  • Like 2

Share this post


Link to post
Share on other sites

Hi,

I'm wondering how unpublished (or hidden) pages could "disappear" from the menu, without having to remove it from the menu?

The context : I have some pages in menu. My user need to unpublished a page not necessary for a temporary period. But it's not automatically removed from the menu. I now deleted from the menu, but I'm quite sure than she will want to re-published it, she will call me because it will not be present in the menu. (I gave her permissions on menu but if I could avoided to touch too much those settings, I will be happy... Anyway, in theory she shouldn't have to modify anything on that module on regular basis).

Thanks

Mel

 

 

Share this post


Link to post
Share on other sites
48 minutes ago, mel47 said:

I'm wondering how unpublished (or hidden) pages could "disappear" from the menu, without having to remove it from the menu?

Hi,

Have a look at your menus settings, specifically the 'Use enable/disable menu items feature'. This requires the permission 'menu-builder-disable-items'. When enabled, you will see under each menu item's settings panel, a checkbox 'Disabled'. Tick that for the menu items you wish to disable and voila; no need to delete them. However, if you do not wish the user to be going to these settings, enabling and disabling menu items, you can instead use getMenuItems() and filter out unpublished and hidden pages. If you can open an issue in the project repo, I can consider to add these as options i.e.  'skip_unpublished'  and 'skip_hidden'. I can't remember of the top of my head how ProcessWire page->viewable() relates to hidden and unpublished pages. We already check for viewable() in menu builder but I'd have to investigate this further.

 

  • Like 3

Share this post


Link to post
Share on other sites

Hi, 

I have some issues since the last update of the module.
If a menu item has children it doesn't get the class provided in the options array (in my case 'menu-item-has-children').
The a tag is not even in a li?!?!

Here is my code:

$options = array(
  'wrapper_list_type' => 'ul',
  'list_type' => 'li',
  'menu_css_id' => '',
  'menu_css_class' => 'menu',
  'submenu_css_class' => 'sub-menu',
  'has_children_class' => 'menu-item-has-children',
  'first_class'=>'',
  'last_class' => '',
  'current_class' => 'current-menu-item',
  'default_title' => 1  ,
  'include_children' => 4,
  'm_max_level' => 2,
  'current_class_level' => 1,
  'default_class' => 'menu-item',
);
  $menu = $modules->get('MarkupMenuBuilder');
  echo $menu->render('hauptmenu', $options);

And this is what comes out (look at Fotografie for example😞
 

<ul class="menu">
  <li class="menu-item">
    <a href="/" class="pm_text_menu_item">Start</a>
  </li>
  	<a href="/fotografie/" class="pm_text_menu_item">Fotografie</a>
  <ul class="sub-menu">
    <a href="/fotografie/landschaften/" class="pm_text_menu_item">Landschaften</a>
    <ul class="sub-menu">
      <li class="menu-item">
        <a href="/fotografie/landschaften/wald/" class="pm_text_menu_item">Wald</a>
      </li>
      <li class="menu-item">
        <a href="/fotografie/landschaften/strand-kuste/" class="pm_text_menu_item">Strand &amp; Küste</a>
      </li>
    </ul>
    <a href="/fotografie/tiere/" class="pm_text_menu_item">Tiere</a>
    <ul class="sub-menu">
      <li class="menu-item">
        <a href="/fotografie/tiere/amphibien-reptilien/" class="pm_text_menu_item">Amphibien &amp; Reptilien</a>
      </li>
      <li class="menu-item">
        <a href="/fotografie/tiere/arthropoden/" class="pm_text_menu_item">Arthropoden</a>
      </li>
      <li class="menu-item">
        <a href="/fotografie/tiere/saugetiere/" class="pm_text_menu_item">Säugetiere</a>
      </li>
      <li class="menu-item">
        <a href="/fotografie/tiere/vogel/" class="pm_text_menu_item">Vögel</a>
      </li>
    </ul>
    <li class="menu-item">
      <a href="/fotografie/stimmungen/" class="pm_text_menu_item">Stimmungen</a>
    </li>
  </ul>
  <li class="menu-item">
    <a href="/video/" class="pm_text_menu_item">Video</a>
  </li>
  <li class="menu-item current-menu-item">
    <a href="/daniel-holte/" class="pm_text_menu_item">Daniel Holte</a>
  </li>
  <li class="menu-item">
    <a href="/kontakt/" class="pm_text_menu_item">Kontakt</a>
  </li>
  <li class="menu-item">
    <a href="/impressum/" class="pm_text_menu_item">Impressum</a>
  </li>
</ul>

So as you can see the li tags for menu items with children are completly missing. I have no idea why and as I said above, I changed nothing except the upadte of the module.

Thanks in advance

Share this post


Link to post
Share on other sites

1. Try rendering the menu without $options.

$menu = $modules->get('MarkupMenuBuilder');
echo $menu->render('hauptmenu');

If the markup is fine then something within your $options doesn't work or

2. Look into your menu settings within the builder. There could be some settings too.

 

I just tried it with version 0.2.5 (which seems to be the latest version) and my menu markup is fine.

Share this post


Link to post
Share on other sites

Found a bit of a bug. If you add javascript:void(0) in the link field in a custom link it deletes the item.

Share this post


Link to post
Share on other sites
1 hour ago, neonwired said:

Found a bit of a bug. If you add javascript:void(0) in the link field in a custom link it deletes the item.

I wouldn't call it a bug. That's the sanitizer at work. For custom things like that, I suggest you use getMenuItems() method to create your menus. See the examples in that link.

Share this post


Link to post
Share on other sites
3 hours ago, neonwired said:

Found a bit of a bug. If you add javascript:void(0) in the link field in a custom link it deletes the item.

Wow. It's 2019 and people are still using this?

@neonwired please read this: https://stackoverflow.com/a/1293130

 

  • Haha 1

Share this post


Link to post
Share on other sites
On 4/16/2019 at 11:20 AM, kongondo said:

I wouldn't call it a bug. That's the sanitizer at work. For custom things like that, I suggest you use getMenuItems() method to create your menus. See the examples in that link.

I'm aware of that. However I doubt deleting the entire entry as a result is intended.

Share this post


Link to post
Share on other sites
On 4/30/2019 at 4:31 PM, neonwired said:

I disagree, it's perfectly legitimate to use it. I don't do code snobbery.

"Anti-snobbery" resulted in my boss recently sending me an email with a link to javascript:void(0);

  • Like 1

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
On 6/13/2019 at 9:31 PM, uiui said:

After adding page number 89 moving items isn't possible anymore as the change won't be saved.

Hi @uiui. I am afraid I don't follow. Could you please explain what page number 89 is?

Also, your ProcessWire version please.

Share this post


Link to post
Share on other sites
Just now, kongondo said:

Hi @uiui. I am afraid I don't follow. Could you please explain what page number 89 is?

Also, your ProcessWire version please.

Hi @kongondo,

I'm working with version 3.0.132.

The menu that produces this error contains 88 pages and a couple of custom links. As soon as I add a page that is counted as number 89, the menu won't save anymore. The last page added doesn't seem to be the origin of the problem as I tried it with a number of different pages.

Share this post


Link to post
Share on other sites
1 hour ago, uiui said:

The menu that produces this error contains 88 pages and a couple of custom links. As soon as I add a page that is counted as number 89, the menu won't save anymore. The last page added doesn't seem to be the origin of the problem as I tried it with a number of different pages.

I've just tested and it works fine. I have created a menu with 93 items. I started with 87 then added more.

  1. How are you adding the menu items? Asm select / Auto complete / Page List / Selector?
  2. Are the menus nested?

Share this post


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

I've just tested and it works fine. I have created a menu with 93 items. I started with 87 then added more.

  1. How are you adding the menu items? Asm select / Auto complete / Page List / Selector?
  2. Are the menus nested?

1. ASM

2. Yes, two levels.

Share this post


Link to post
Share on other sites
1 hour ago, uiui said:

1. ASM

2. Yes, two levels.

I have tested again, this time adding items one at a time using ASM select, creating a two-level deep menu with 93 items. Some of the items were repeated though.  I also added a number of custom menu items. 

Are you able to show me screenshot, or, preferably, a video of the offending menu? The video would need to show the bit about the 89th item please. Ideally, have Tracy Debugger on to catch any errors as well. 

  • Is this a local or remote site?
  • Single or Multilingual? 
  • Third-party modules in use?

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   2 members

  • Similar Content

    • By horst
      ---------------------------------------------------------------------------------------------------------------------------------
        when working with PW version 2.6+, please use Pim2, not Pim!
        read more here  on how to change from the older to the newer version in existing sites
      ---------------------------------------------------------------------------------------------------------------------------------
      PageImage Manipulator, API for version 1 & 2

      The Page Image Manipulator is a module that let you in a first place do ImageManipulations with your PageImages. - And in a second place there is the possibility to let it work on any imagefile that exists in your servers filesystem, regardless if it is a 'known PW-image'.

      The Page Image Manipulator is a Toolbox for Users and Moduledevelopers. It is written to be as close to the Core ImageSizer as possible. Besides the GD-filterfunctions it contains resize, crop, canvas, rotate, flip, sharpen, unsharpMask and 3 watermark methods.



      How does it work?

      You can enter the ImageManipulator by calling the method pim2Load(). After that you can chain together how many actions in what ever order you like. If your manipulation is finished, you call pimSave() to write the memory Image into a diskfile. pimSave() returns the PageImage-Object of the new written file so we are able to further use any known PW-image property or method. This way it integrates best into the ProcessWire flow.

      The three examples above put out the same visual result: a grayscale image with a width of 240px. Only the filenames will slightly differ.

      You have to define a name-prefix that you pass with the pimLoad() method. If the file with that prefix already exists, all operations are skipped and only the desired PageImage-Object gets returned by pimSave(). If you want to force recreation of the file, you can pass as second param a boolean true: pim2Load('myPrefix', true).

      You may also want to get rid of all variations at once? Than you can call $pageimage->pim2Load('myPrefix')->removePimVariations()!

      A complete list of all methods and actions are at the end of this post.
       
      You may also visit the post with tips & examples for users and module developers.


      How to Install
      Download the module Place the module files in /site/modules/PageImageManipulator/ In your admin, click Modules > Check for new modules Click "install" for PageImageManipulator Done! There are no configuration settings needed, just install and use it. Download    (version 0.2.0)
      get it from the Modules Directory History of origins

      http://processwire.com/talk/topic/3278-core-imagemanipulation/


      ----------------------------------------------------------------------------------------------------------


      Page Image Manipulator - Methods

      * pimLoad  or  pim2Load, depends on the version you use!

      pimLoad($prefix, $param2=optional, $param3=optional)
      param 1: $prefix - (string) = mandatory! param 2: mixed, $forceRecreation or $options param 3: mixed, $forceRecreation or $options return: pim - (class handle) $options - (array) default is empty, see the next method for a list of valid options! $forceRecreation - (bool) default is false It check if the desired image variation exists, if not or if forceRecreation is set to true, it prepares all settings to get ready for image manipulation
      -------------------------------------------------------------------

      * setOptions

      setOptions(array $options)
      param: $options - (array) default is empty return: pim - (class handle) Takes an array with any number valid options / properties and set them by replacing the class-defaults and / or the global config defaults optionally set in the site/config.php under imageSizerOptions or imageManipulatorOptions.

      valid options are:
      quality = 1 - 100 (integer) upscaling = true | false (boolean) cropping = true | false (boolean) autoRotation =true | false (boolean) sharpening = 'none' | 'soft' | 'medium' | 'strong' (string) bgcolor = (array) css rgb or css rgba, first three values are integer 0-255 and optional 4 value is float 0-1, - default is array(255,255,255,0) thumbnailColorizeCustom = (array) rgb with values for colorize, integer -255 - 255 (this can be used to set a custom color when working together with Thumbnails-Module)
        outputFormat = 'gif' | 'jpg' | 'png' (Attention: outputFormat cannot be specified as global option in $config->imageManipulatorOptions!) set {singleOption} ($value)
      For every valid option there is also a single method that you can call, like setQuality(90), setUpscaling(false), etc.
      -------------------------------------------------------------------

      * pimSave

      pimSave()
      return: PageImage-Object If a new image is hold in memory, it saves the current content into a diskfile, according to the settings of filename, imagetype, targetFilename and outputFormat. Returns a PageImage-Object!
      -------------------------------------------------------------------

      * release

      release()
      return: void (nothing) if you, for what ever reason, first load image into memory but than do not save it, you should call release() to do the dishes! 😉 If you use pimSave() to leave the ImageManipulator, release() is called automatically.
      -------------------------------------------------------------------

      * getOptions

      getOptions()
      return: associative array with all final option values example:
      ["autoRotation"] bool(true) ["upscaling"] bool(false) ["cropping"] bool(true) ["quality"] int(90) ["sharpening"] string(6) "medium" ["targetFilename"] string(96) "/htdocs/site/assets/files/1124/pim_prefix_filename.jpg" ["outputFormat"] string(3) "jpg" get {singleOption} ()
      For every valid option there is also a single method that you can call, like getQuality(), getUpscaling(), etc. See method setOptions for a list of valid options!
      -------------------------------------------------------------------

      * getImageInfo

      getImageInfo()
      return: associative array with useful informations of source imagefile example:
      ["type"] string(3) "jpg" ["imageType"] int(2) ["mimetype"] string(10) "image/jpeg" ["width"] int(500) ["height"] int(331) ["landscape"] bool(true) ["ratio"] float(1.5105740181269) ["bits"] int(8) ["channels"] int(3) ["colspace"] string(9) "DeviceRGB" -------------------------------------------------------------------

      * getPimVariations

      getPimVariations()
      return: array of Pageimages Collect all pimVariations of this Pageimage as a Pageimages array of Pageimage objects. All variations created by the core ImageSizer are not included in the collection.
      -------------------------------------------------------------------

      * removePimVariations

      removePimVariations()
      return: pim - (class handle) Removes all image variations that was created using the PIM, all variations that are created by the core ImageSizer are left untouched!
      -------------------------------------------------------------------
      * width

      width($dst_width, $sharpen_mode=null)
      param: $dst_width - (integer) param: $auto_sharpen - (boolean) default is true was deleted with version 0.0.8, - sorry for breaking compatibility param: $sharpen_mode - (string) possible: 'none' | 'soft' | 'medium' | 'strong', default is 'soft' return: pim - (class handle) Is a call to resize where you prioritize the width, like with pageimage. Additionally, after resizing, an automatic sharpening can be done with one of the three modes.
      -------------------------------------------------------------------

      * height

      height($dst_height, $sharpen_mode=null)
      param: $dst_height - (integer) param: $auto_sharpen - (boolean) default is true was deleted with version 0.0.8, - sorry for breaking compatibility param: $sharpen_mode - (string) possible: 'none' | 'soft' | 'medium' | 'strong', default is 'soft' return: pim - (class handle) Is a call to resize where you prioritize the height, like with pageimage. Additionally, after resizing, an automatic sharpening can be done with one of the three modes.
      -------------------------------------------------------------------

      * resize

      resize($dst_width=0, $dst_height=0, $sharpen_mode=null)
      param: $dst_width - (integer) default is 0 param: $dst_height - (integer) default is 0 param: $auto_sharpen - (boolean) default is true was deleted with version 0.0.8, - sorry for breaking compatibility param: $sharpen_mode - (string) possible: 'none' | 'soft' | 'medium' | 'strong', default is 'soft' return: pim - (class handle) Is a call to resize where you have to set width and / or height, like with pageimage size(). Additionally, after resizing, an automatic sharpening can be done with one of the three modes.
      -------------------------------------------------------------------

      * stepResize

      stepResize($dst_width=0, $dst_height=0)
      param: $dst_width - (integer) default is 0 param: $dst_height - (integer) default is 0 return: pim - (class handle) this performs a resizing but with multiple little steps, each step followed by a soft sharpening. That way you can get better result of sharpened images.
      -------------------------------------------------------------------

      * sharpen

      sharpen($mode='soft')
      param: $mode - (string) possible values 'none' | 'soft'| 'medium'| 'strong' return: pim - (class handle) Applys sharpening to the current memory image. You can call it with one of the three predefined pattern, or you can pass an array with your own pattern.
      -------------------------------------------------------------------

      * unsharpMask

      unsharpMask($amount, $radius, $threshold)
      param: $amount - (integer) 0 - 500, default is 100 param: $radius - (float) 0.1 - 50, default is 0.5 param: $threshold - (integer) 0 - 255, default is 3 return: pim - (class handle) Applys sharpening to the current memory image like the equal named filter in photoshop.
      Credit for the used unsharp mask algorithm goes to Torstein Hønsi who has created the function back in 2003.
      -------------------------------------------------------------------

      * smooth

      smooth($level=127)
      param: $level - (integer) 1 - 255, default is 127 return: pim - (class handle) Smooth is the opposite of sharpen. You can define how strong it should be applied, 1 is low and 255 is strong.
      -------------------------------------------------------------------

      * blur

      blur()
      return: pim - (class handle) Blur is like smooth, but cannot called with a value. It seems to be similar like a result of smooth with a value greater than 200.
      -------------------------------------------------------------------

      * crop

      crop($pos_x, $pos_y, $width, $height)
      param: $pos_x - (integer) start position left param: $pos_y - (integer) start position top param: $width - (integer) horizontal length of desired image part param: $height - (integer) vertical length of desired image part return: pim - (class handle) This method cut out a part of the memory image.
      -------------------------------------------------------------------

      * canvas

      canvas($width, $height, $bgcolor, $position, $padding)
      param: $width = mixed, associative array with options or integer, - mandatory! param: $height = integer, - mandatory if $width is integer! param: $bgcolor = array with rgb or rgba, - default is array(255, 255, 255, 0) param: $position = one out of north, northwest, center, etc, - default is center param: $padding = integer as percent of canvas length, - default is 0 return: pim - (class handle) This method creates a canvas according to the given width and height and position the memory image onto it.
      You can pass an associative options array as the first and only param. With it you have to set width and height and optionally any other valid param. Or you have to set at least width and height as integers.
      Hint: If you want use transparency with rgba and your sourceImage isn't of type PNG, you have to define 'png' as outputFormat with your initially options array or, for example, like this: $image->pimLoad('prefix')->setOutputFormat('png')->canvas(300, 300, array(210,233,238,0.5), 'c', 5)->pimSave()
      -------------------------------------------------------------------

      * flip

      flip($vertical=false)
      param: $vertical - (boolean) default is false return: pim - (class handle) This flips the image horizontal by default. (mirroring)
      If the boolean param is set to true, it flips the image vertical instead.
      -------------------------------------------------------------------

      * rotate

      rotate($degree, $backgroundColor=127)
      param: $degree - (integer) valid is -360 0 360 param: $backgroundColor - (integer) valid is 0 - 255, default is 127 return: pim - (class handle) This rotates the image. Positive values for degree rotates clockwise, negative values counter clockwise. If you use other values than 90, 180, 270, the additional space gets filled with the defined background color.
      -------------------------------------------------------------------

      * brightness

      brightness($level)
      param: $level - (integer) -255 0 255 return: pim - (class handle) You can adjust brightness by defining a value between -255 and +255. Zero lets it unchanged, negative values results in darker images and positive values in lighter images.
      -------------------------------------------------------------------

      * contrast

      contrast($level)
      param: $level - (integer) -255 0 255 return: pim - (class handle) You can adjust contrast by defining a value between -255 and +255. Zero lets it unchanged, negative values results in lesser contrast and positive values in higher contrast.
      -------------------------------------------------------------------

      * grayscale

      grayscale()
      return: pim - (class handle) Turns an image into grayscale. Remove all colors.
      -------------------------------------------------------------------

      * sepia

      sepia()
      return: pim - (class handle) Turns the memory image into a colorized grayscale image with a predefined rgb-color that is known as "sepia".
      -------------------------------------------------------------------

      * colorize

      colorize($anyColor)
      param: $anyColor - (array) like css rgb or css rgba - but with values for rgb -255 - +255,  - value for alpha is float 0 - 1, 0 = transparent  1 = opaque return: pim - (class handle) Here you can adjust each of the RGB colors and optionally the alpha channel. Zero lets the channel unchanged whereas negative values results in lesser / darker parts of that channel and higher values in stronger saturisation of that channel.
      -------------------------------------------------------------------

      * negate

      negate()
      return: pim - (class handle) Turns an image into a "negative".
      -------------------------------------------------------------------

      * pixelate

      pixelate($blockSize=3)
      param: $blockSize - (integer) 1 - ??, default is 3 return: pim - (class handle) This apply the well known PixelLook to the memory image. It is stronger with higher values for blockSize.
      -------------------------------------------------------------------

      * emboss

      emboss()
      return: pim - (class handle) This apply the emboss effect to the memory image.
      -------------------------------------------------------------------

      * edgedetect

      edgedetect()
      return: pim - (class handle) This apply the edge-detect effect to the memory image.
      -------------------------------------------------------------------

      * getMemoryImage

      getMemoryImage()
      return: memoryimage - (GD-Resource) If you want apply something that isn't available with that class, you simply can check out the current memory image and apply your image - voodoo - stuff
      -------------------------------------------------------------------

      * setMemoryImage

      setMemoryImage($memoryImage)
      param: $memoryImage - (GD-Resource) return: pim - (class handle) If you are ready with your own image stuff, you can check in the memory image for further use with the class.
      -------------------------------------------------------------------

      * watermarkLogo

      watermarkLogo($pngAlphaImage, $position='center', $padding=2)
      param: $pngAlphaImage - mixed [systemfilepath or PageImageObject] to/from a PNG with transparency param: $position - (string) is one out of: N, E, S, W, C, NE, SE, SW, NW,
      - or: north, east, south, west, center, northeast, southeast, southwest, northwest
      default is 'center' param: $padding - (integer) 0 - 25, default is 5, padding to the borders in percent of the images length! return: pim - (class handle) You can pass a transparent image with its filename or as a PageImage to the method. If the watermark is bigger than the destination-image, it gets shrinked to fit into the targetimage. If it is a small watermark image you can define the position of it:
      NW - N - NE | | | W - C - E | | | SW - S - SE  
      The easiest and best way I have discovered to apply a big transparency watermark to an image is as follows:
      create a square transparent png image of e.g. 2000 x 2000 px, place your mark into the center with enough (percent) of space to the borders. You can see an example here! The $pngAlphaImage get centered and shrinked to fit into the memory image. No hassle with what width and / or height should I use?, how many space for the borders?, etc.
      -------------------------------------------------------------------

      * watermarkLogoTiled

      watermarkLogoTiled($pngAlphaImage)
      param: $pngAlphaImage - mixed [systemfilepath or PageImageObject] to/from a PNG with transparency return: pim - (class handle) Here you have to pass a tile png with transparency (e.g. something between 150-300 px?) to your bigger images. It got repeated all over the memory image starting at the top left corner.
      -------------------------------------------------------------------

      * watermarkText

      watermarkText($text, $size=10, $position='center', $padding=2, $opacity=50, $trueTypeFont=null)
      param: $text - (string) the text that you want to display on the image param: $size - (integer) 1 - 100, unit = points, good value seems to be around 10 to 15 param: $position - (string) is one out of: N, E, S, W, C, NE, SE, SW, NW,
      - or: north, east, south, west, center, northeast, southeast, southwest, northwest
      default is 'center' param: $padding - (integer) 0 - 25, default is 2, padding to the borders in percent of the images length! param: $opacity- (integer) 1 - 100, default is 50 param: $trueTypeFont - (string) systemfilepath to a TrueTypeFont, default is freesansbold.ttf (is GPL & comes with the module) return: pim - (class handle) Here you can display (dynamic) text with transparency over the memory image. You have to define your text, and optionally size, position, padding, opacity for it. And if you don't like the default font, freesansbold, you have to point to a TrueTypeFont-File of your choice.
      Please have a look to example output: http://processwire.com/talk/topic/4264-release-page-image-manipulator/page-2#entry41989
      -------------------------------------------------------------------





      PageImage Manipulator - Example Output


    • By d'Hinnisdaël
      Format Datetime fields as Carbon instances.
      You can find the latest release and the complete readme on Github.
      Installation
      composer require daun/datetime-carbon-format Usage
      All Datetime fields will now be formatted as Carbon instances instead of strings. Some examples:
      // $page->date is a Datetime field // Output format: j/n/Y echo $page->date; // 20/10/2020 echo $page->date->add('7 days'); // 27/10/2020 echo $page->date->format('l, F j'); // Monday, October 20 echo $page->date->year; // 2020 echo $page->date->diffForHumans(); // 28 minutes ago Frontend only
      The ProcessWire admin seems to expect datetime fields to be strings. This module will only return Carbon instances on frontend page views.
      Date output format
      When casting a Carbon instance to a string (usually when outputting the field in a template), the field's date output format will be respected.
      Links
      GitHub • Readme • Carbon docs
       
       
      PS. I remember reading about a Carbon module in a recent newsletter, but couldn't find it anywhere. Was that you, @bernhard?
    • By MoritzLost
      TrelloWire
      This is a module that allows you to automatically create Trello cards for ProcessWire pages and update them when the pages are updated. This allows you to setup connected workflows. Card properties and change handling behaviour can be customized through the extensive module configuration. Every action the module performs is hookable, so you can modify when and how cards are created as much as you need to. The module also contains an API-component that makes it easy to make requests to the Trello API and build your own connected ProcessWire-Trello workflows.
      Warning: This module requires ProcessWire 3.0.167 which is above the current stable master release at the moment.
      Features
      All the things the module can do for you without any custom code: Create a new card on Trello whenever a page is added or published (you can select applicable templates). Configure the target board, target list, name and description for new cards. Add default labels and checklists to the card. Update the card whenever the page is updated (optional). When the status of the card changes (published / unpublished, hidden / unhidden, trashed / restored or deleted), move the card to a different list or archive or delete it (configurable). You can extend this through hooks in many ways: Modifiy when and how cards are created. Modify the card properties (Target board & list, title, description, et c.) before they are sent to Trello. Create your own workflows by utilizing an API helper class with many convenient utility methods to access the Trello API directly. Feedback & Future Plans
      Let me know what you think! In particular:
      If you find any bugs report them here or on Github, I'll try to fix them. This module was born out of a use-case for a client project where we manage new form submissions through Trello. I'm not sure how many use-cases there are for this module. If you do use it, tell me about it! The Trello API is pretty extensive, I'll try to add some more helper methods to the TrelloWireApi class (let me know if you need anything in particular). I'll think about how the module can support different workflows that include Twig – talk to me if you have a use-case! Next steps could be a dashboard to manage pages that are connected to a Trello card, or a new section in the settings tab to manage the Trello connection. But it depends on whether there is any interest in this 🙂 Links
      Repository on Github Complete module documentation (getting started, configuration & API documentation) TrelloWire in the modules directory Module configuration

×
×
  • Create New...