horst

Pia - Pageimage Assistant

Recommended Posts

Pia - Pageimage Assistant

Hello, today I can tell you that Pia Ballerina want to assist you with Pageimages   pia-ballerina_titel.jpg
and that can become really helpful! :)
.
.
.
Pia, in its current state, version 1.0.0, provides:

  • a GUI (the module config screen) for quick and easy changes to the sitewide Pageimage default options
     
  • an alternative way for calling the Pageimage resizing methods with PW selector strings
     
  • three new methods as shortcuts to the resizing functions
     
  • a new method called retinafy and its alias hiDPI, (introduced in version 0.2.0)

.
.
.
2) Instead of ->width(), ->height(), ->size() you can call ->pia() now. With a PW selector string you tell Pia what image variation you want to have :
.

$image->pia("width=100, quality=80, sharpening=medium")->url;

.
If you want process ->width() just define width.
If you want process ->height() only define height.
If you want process ->size() just define width and height.
If you want process ->size() with equal values for width and height, just define only size, or use the alias square:
.

$image->pia("width=480")->url;
$image->pia("height=320")->url;
$image->pia("width=400, height=300")->url;
$image->pia("size=350")->url;
$image->pia("square=350")->url;

.
So, yes, - I see. Now you may think: "Ok, nice looking girl, - and she can dance very well, - but for what should it be good that she is involved here? My very old buddies width, height and size - and me, - we don't need any Ballerinas between us!"
.
Yeah, I see what you mean. But this above is not what Pia is good for, this is just a little warming up for you. :)
.
In some cases one need to specify more than just width and / or height. If it comes to that you need explicitly populated options with the individual pageimages, Pia will become faster and more comfortable at some point. Also the code is looking more readable with Pia, at least to me:
.

// regular style #1:

$image->width(800, array("upscaling" => false, "cropping" => true, "quality" => 80, "sharpening" => "strong"));

// or regular style #2:

$options = array("upscaling" => false, "cropping" => true, "quality" => 80, "sharpening" => "strong");
$image->width(800, $options);

// now lets Pia dance:

$image->pia('width=800, upscaling=0, cropping=1, quality=80, sharpening=strong');

$image->pia('width=800, upscaling=off, cropping=on, quality=80, sharpening=strong');

.
For me it is that not only Pia begin to dance, my fingers do so too when writing selector strings instead of the regular array code. :)
.  
Ok, last thing before we can go to stage: "You already may have noticed that Pia accepts few different values for boolean expression, yes?"

  • for TRUE you can write these strings: "1, on, ON, true, TRUE, -1"
  • for FALSE you may use one out of "0, off, OFF, false, FALSE"

Ready? Ok, lets go to stage.
.
.
.
3) Pia provide three new methods as shortcuts. This means that when using one of the shortcuts you have pre-populated options, regardless of the sitewide default settings:

  • crop :: does what the name says
     
  • contain :: is equal to the regular method: ->size($width, $height, array("cropping" => false))
     
  • cover :: this, Pias third child, is a new kid on the block :)

.
Let's have a closer look and compare it. We use Pias image from above as source for this example. (It's dimensions are 289 x 400 px)
.
.
* crop

$image->crop('square=100'); 

.
pia-ballerina_titel.100x100-piacrop.jpg    it is 100 x 100 px    and the name is:  pia-ballerina_titel.100x100-piacrop.jpg
.
.
.
* contain

$image->contain('square=100');

.
pia-ballerina_titel.100x100-piacontain.j    it is 73 x 100 px   and the name is:  pia-ballerina_titel.100x100-piacontain.jpg
.
.
.
* cover

$image->cover('square=100'); 

.
pia-ballerina_titel.100x139-piacover.jpg    it is 100 x 139 px   and the name is:  pia-ballerina_titel.100x139-piacover.jpg
.
.
.
Ok, you got it?
.
"Crop" crop out the area, "Contain" fits the image into the area, and "Cover" calculates the needed dimensions for the image so that the area is completly covered by it.
.
Following is a link with lots of those crop-, contain-, cover- variations. I have stress-tested it a bit: much variations
.
----------
.
.
Later Additions:
.
* contain with option weighten
Since version 0.0.6 contain can take an additional param called "weighten". (read more here)
.
.
.

* retinafy
Since version 0.2.0 retinafy is added. It returns a markup string, e.g. a HTML img tag, where placeholders are populated with property values from the pageimage. Default properties are: URL, WIDTH, HEIGHT, DESCRIPTION. The method also can take an optional array with CustomPropertyNames. You also can use the alias HiDPI if you like. (read more here)

.
.
----------
.
.
You can get the module from the modules directory or from the repo on Github:
.

git clone https://github.com/horst-n/PageimageAssistant.git your/path/site/modules/PageimageAssistant

.
.
Bye! 
.

 

pia-ballerina_outro.jpg

Classical ballet performance at the Aalto Theatre in Essen, in the context of the Red Dot Award ceremony 26 June 2007,
Act III, Sleeping Beauty, the wedding reception
Photos: Horst Nogajski - www.nogajski.de

 

  • Like 35

Share this post


Link to post
Share on other sites

It is incredible how it is in this PW forum, You go to sleep, you wake up, turn the computer on, and you find another jewel! It is all around the globe so magic just never stops! It is like a new year every day with presents under the tree. Thank you, mr. Horst!

And something on the substance:

1) It would be usefull in many cases (at least for me) to have a 4th method, which would act like contain, but would fill with adjustable color spaces to the left and right (or to the up and down if it is horisontal) making the thumb a squre, but still containing the whole of the image. Like this:

post-2275-0-94617800-1416728404.jpg

2) Could you please write a bit about how you work with images. We now have options from you: pim and pia (not forgetting about core methods). How do they work together? Should we use both or just one of them and in what cases?

  • Like 2

Share this post


Link to post
Share on other sites

It is incredible how it is in this PW forum, You go to sleep, you wake up, turn the computer on, and you find another jewel! It is all around the globe so magic just never stops! It is like a new year every day with presents under the tree. Thank you, mr. Horst!

So true.  :rolleyes: Thanks horst. Pia is one fine lady.

  • Like 1

Share this post


Link to post
Share on other sites

1) It would be usefull in many cases (at least for me) to have a 4th method, which would act like contain, but would fill with adjustable color spaces to the left and right (or to the up and down if it is horisontal) making the thumb a squre, but still containing the whole of the image. Like this:

2) Could you please write a bit about how you work with images. We now have options from you: pim and pia (not forgetting about core methods). How do they work together? Should we use both or just one of them and in what cases?

thanks for the nice words.

1) unfortunately Pia only assist with preparing and delegating values to the images engines. She isn't able to process images her self.

What you are requesting is "canvas", it is provided by Pim. I don't know yet if Pia dynamically should support shortcuts depending on other installed modules or not. It can become a bit confusing. On the other hand I see how comfortable it could be if Pia would assist here too.

2) I will do so when finding a bit time for it.

So true.  :rolleyes: Thanks horst. Pia is one fine lady.

yes, she is! 

pia--one-fine-lady.jpg

  • Like 2

Share this post


Link to post
Share on other sites

Updated to version 4

- I had to fix the forceNew option what may be used during site develope.

- also have changed a bit on the GUI: it detects if you have Fieldtype RangeSlider installed and uses that over a regular Integer Inputfield for Quality-Setting

If you are already using it, please update too.

Edited by horst
added change to version 4
  • Like 2

Share this post


Link to post
Share on other sites

Hey horst - looks awesome, but I am running php 5.3.28 on my dev server (just to pick up on things like this) and get a parse error due to:

InputfieldRangeSlider::getModuleInfo()['version'] on line 345

Something like this takes care of it:

if($modules->isInstalled('InputfieldRangeSlider')) $rangeSliderInfo = InputfieldRangeSlider::getModuleInfo();
$hasSlider = $modules->isInstalled('InputfieldRangeSlider') && version_compare($rangeSliderInfo['version'], '1.0.4', '>=');
One minor typo while I think of it:
here you can set sitewide options, - this overrides the options from site/config.php
 
This is under the main config and also the advances section. As well as the missing "s", probably also don't need the comma and the hyphen.
  • Like 2

Share this post


Link to post
Share on other sites

@Adrian: thanks for the feedback. Here she is a bit to modern I believe. I will change this soon! ^-^

  • Like 5

Share this post


Link to post
Share on other sites

Hi Horst,

Many times I need to output a lot of logo's. Those logo's need to have the same visual weight. Some logo's need to be wider others need to be higher. May I purpose a new method 'logo' or something ?

Pia is dancing nicely with crop contain and cover, but could you let her swing with logo ?

I have a starting point here that works great (used it many times)

  • Like 3

Share this post


Link to post
Share on other sites

Hi Martijn,

you mean you have a module that outputs images of different aspect ratios in a visual weighted manner?

This would be nice to have, once we have discussed on that already.

Regarding the name 'logo' I'm not sure. Can we find a more descriptive one?

visualWeighted is to long, :lol:

  • Like 1

Share this post


Link to post
Share on other sites

New addition to contain: weighten!
 
If you want to put some images of different aspect ratio onto a webpage and you want that they are displayed more equal visual weightened, you can use this method and options now:
.
* contain with option weighten

$image->contain('square=90, weighten=on');

.
.
There is also the possibility to prioritize portrait or landscape oriented images:
.

$image->contain('square=90, weighten=x1');  // landscapes are a bit larger than portraits

$image->contain('square=90, weighten=x2');  // landscapes are a bit more larger than portraits

$image->contain('square=90, weighten=y1');  // portraits are a bit larger than landscapes 

$image->contain('square=90, weighten=y2');  // portraits are a bit more larger than landscapes 

.
.
Have a look to this output here:
.
pia_weighten_overview.jpg
.
.
.
.
PS:
@Martijn: I have taken your code for the calculations and set the percent value hard coded to 38. This way we only need to turn weighten on or off and have not to deal with values here. The only thing I have added to the calculation is an adjustment to fit better with the largest dimension into the initial bounding box dimensions. (Github)

  • Like 7

Share this post


Link to post
Share on other sites

Big thanks Horst

 

The only thing I have added to the calculation is an adjustment to fit better with the largest dimension into the initial bounding box dimensions. (Github)

 

Thats why I used a rectangular box in the Gist to control it.

  • Like 1

Share this post


Link to post
Share on other sites

Thats why I used a rectangular box in the Gist to control it.

Yes, I know and I have used it initially that way. And you also can do it now: when passing width and height instead of square, the other possible options are ignored and the result should be similar to what you have got with the gist code, but maybe a bit larger. (20%)

I thought it would be easier and less confusion for average users to just have a switch for on/off and if they define a square of 120 that they get back the largest possible image with 120px.

If you also like / need the comp param dynamically to define, it can be easily added as a 'silent' option. :)

  • Like 1

Share this post


Link to post
Share on other sites

I have updated the module to Version 0.1.0 beta and it has a new addition to the weighten option that can be used together with contain.
 
The initial code I have taken for weighten calculations is from Martijn. I have changed it to simplify its usage so that you only need to specify a bounding square and have to switch it on, or additionaly prioritize landscape oriented images in two favours: x1, x2 or do the same for portrait oriented images with: y1, y2. (read more in the posts above)
 
But if you (@Martijn ;) ) like to use more different options, like with the original ImageFitBoundaries.module, you can use it by specifying different values for width and height together with the new value "comp##". For ## you set the value for compression like comp20, comp30, comp40 or whatever you like.

:)

  • Like 6

Share this post


Link to post
Share on other sites

But if you (@Martijn ;) ) like to use more different options, like with the original ImageFitBoundaries.module, you can use it by specifying different values for width and height together with the new value "comp##". For ## you set the value for compression like comp20, comp30, comp40 or whatever you like.

Don't know if it is already in. But I used ImageFitBoundaries with a 'double' loop. Let me explane :-)

- looping several images through the Module and get the widest value. (No images are scaled, only values are returned)

- then I search the widest image, and take the percentage it is compaired to the box.

- I use that percentage to scale all images up.

  • Like 1

Share this post


Link to post
Share on other sites

Don't know if it is already in. But I used ImageFitBoundaries with a 'double' loop. Let me explane :-)

- looping several images through the Module and get the widest value. (No images are scaled, only values are returned)

- then I search the widest image, and take the percentage it is compaired to the box.

- I use that percentage to scale all images up.

No, it isn't in like you explained here, but it is somehow in without a double loop. But only when using a square boundary box and when the images are between the ratio aspects 1:2 -> 2:1. Images with more extreme ratio aspects are scaled none linear so that those are displayed smaller.

So, the normal usage of weighten works like your description but is assuming the ratio aspect isn't wider than 2:1 / 1:2.

When we add an additional param for the widest aspect ratio we should get the same effect as you described, I think.

You first have to run a loop through the images, fetching their aspect ratios, and afterwards pass the highest value to the contain-weighten call.

With images == photgraphs I think the average usage is well covered the way how it is setup now. But with logos it could be go much further with aspect ratios. Maybe you can drop in a small list of real logo usage aspect ratios (with extremes), so that I get a grasp of what we are talking here?

  • Like 1

Share this post


Link to post
Share on other sites

I've used the 'double loop' in pluimveeweb on the right side with the "Kennispartners" logo's. Now there's only 1 partner but when there are 3 or more (2 logo's always visible) it'll get to the widest value possible for the widest logo. 336px / 2 = 168px.

Here's some example code that will explain it better.

$compress = 40; // heavier images compress more
$x = 400; // box size, reference for image
$y = 280; // box size, reference for image
$max = 0; // calculation of the widests image, used to scale all others.

// calculate max width all images ( settings as wide as possible )
foreach($partners as $partner) {
    $image = $partner->generic_logo;
    if($image instanceof Pageimage) {
        $box = $modules->get("ImageFitBoundaries");
        $info = $box->load($image, $x, $y, $compress)->info();
        $max = $max < $info['width'] ? $info['width'] : $max;
    }
}

$percent = 168 * 100 / $max; // 2 X 168 = 336px width of the column

foreach($partners as $partner) {
    $image = $partner->generic_logo;
    
    if($image instanceof Pageimage) {
    
        $box = $modules->get("ImageFitBoundaries");
        $info = $box->load($image, $x, $y, $compress)->info();
        $width = (int) round($info['width'] / 100 * $percent);
        $height = (int) round($info['height'] / 100 * $percent);

        $options = array(
            'quality' => 100,
            'sharpening' => 'none'
        );

        $thumb = $image->size($width, $height, $options);
    }
}

I'm really happy how much you've implemented so far and I think you should not over complicate the module. I think you should leave it how it is now.

Thanks again for implementing weighten !

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for giving those insights. I have made a note to the additional param for wider aspect ratios, what wouldn't be much work to implement, but will wait if other users request support for weighten with those wider aspect ratios.

Thanks for your help with this. :)

  • Like 1

Share this post


Link to post
Share on other sites

New addition: retinafy!

this was created on request from @jjozsi here in this post.
.
* retinafy

// create a pageimage with any method you like
$image = $page->images->first()->size(400, 300);  

// call retinafy on it
echo $image->retinafy();

// it outputs a markup string like this, where width and height is populated with half the sizes of the pageimage
<img src="/site/assets/files/1234/basename.400x300.jpg" width="200" height="150" alt="description" />

.
.
The default markup template has the default replacements URL, WIDTH, HEIGHT and DESCRIPTION.

<img src="[URL]" width="[WIDTH]" height="[HEIGHT]" alt="[DESCRIPTION]" />

You can change that to any markup you like in the modules Configpage!

.
.
If you have additional properties populated with pageimages in your system, you can provide an array with those property names:

// if you need custom properties in your markup, define the template in the modules config page with those placeholders, 
// please only use UPPERCASE and wrapp these [ ] around them
<img src="[URL]" width="[WIDTH]" height="[HEIGHT]" data-custom1="[CUSTOM1]" data-custom2="[CUSTOM2]" />

// call retinafy with custom property names
$customPropertyNames = array("custom1", "custom2");
echo $image->retinafy($customPropertyNames);

// it outputs a markup string like this, where width and height is populated with half the sizes of the pageimage
<img src="/site/assets/files/1234/basename.400x300.jpg" width="200" height="150" data-custom1="custom-value-1" data-custom2="custom-value-2" />

.
.

Regarding to the technique described in the article @jjozsi linked to in his post it would make much sense to use a low quality setting sitewide by defining it in the ImageSizerOptions, also available on the Pia Configpage. Otherwise, if this is not possible, you need to call your images for that you want the retinafy markup with the quality option set:

// create a pageimage with any method you like
echo $page->images->first()->size(400, 300, array("quality"=>35))->retinafy(); 
Edited by horst
  • Like 5

Share this post


Link to post
Share on other sites

Have updated Pia to 0.2.2 because she also was affected by the same issue as CroppableImage. Recent PW versions now (can) log modules API actions into logfile modules.txt. This is suppressed now. If you use Pia and a recent PW dev version, please update to 0.2.2. http://modules.processwire.com/modules/pageimage-assistant/

  • Like 2

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 horst
      Wire Mail SMTP

      An extension to the new WireMail base class that uses SMTP-transport

      This module integrates EmailMessage, SMTP and SASL php-libraries from Manuel Lemos into ProcessWire. I use this continously evolved libraries for about 10 years now and there was never a reason or occasion not to do so. I use it nearly every day in my office for automated composing and sending personalized messages with attachments, requests for Disposition Notifications, etc. Also I have used it for sending personalized Bulkmails many times.

      The WireMailSmtp module extends the new email-related WireMail base class introduced in ProcessWire 2.4.1 (while this writing, the dev-branch only).
       
      Here are Ryans announcement.



      Current Version 0.2.6
      get it from the Modules Directory Install and Configure

      Download the module into your site/modules/ directory and install it.

      In the config page you fill in settings for the SMTP server and optionaly the (default) sender, like email address, name and signature.
      You can test the smtp settings directly there. If it says "SUCCESS! SMTP settings appear to work correctly." you are ready to start using it in templates, modules or bootstrap scripts.


      Usage Examples
      The simplest way to use it:
      $numSent = wireMail($to, $from, $subject, $textBody); $numSent = wireMail($to, '', $subject, $textBody); // or with a default sender emailaddress on config page This will send a plain text message to each recipient.
       
      You may also use the object oriented style:
      $mail = wireMail(); // calling an empty wireMail() returns a wireMail object $mail->to($toEmail, $toName); $mail->from = $yourEmailaddress; // if you don't have set a default sender in config // or if you want to override that $mail->subject($subject); $mail->body($textBody); $numSent = $mail->send(); Or chained, like everywhere in ProcessWire:
      $mail = wireMail(); $numSent = $mail->to($toEmail)->subject($subject)->body($textBody)->send(); Additionaly to the basics there are more options available with WireMailSmtp. The main difference compared to the WireMail BaseClass is the sendSingle option. With it you can set only one To-Recipient but additional CC-Recipients.
      $mail = wireMail(); $mail->sendSingle(true)->to($toEmail, $toName)->cc(array('person1@example.com', 'person2@example.com', 'person3@example.com')); $numSent = $mail->subject($subject)->body($textBody)->send(); The same as function call with options array:
      $options = array( 'sendSingle' => true, 'cc' => array('person1@example.com', 'person2@example.com', 'person3@example.com') ); $numSent = wireMail($to, '', $subject, $textBody, $options); There are methods to your disposal to check if you have the right WireMail-Class and if the SMTP-settings are working:
      $mail = wireMail(); if($mail->className != 'WireMailSmtp') { // Uups, wrong WireMail-Class: do something to inform the user and quit echo "<p>Couldn't get the right WireMail-Module (WireMailSmtp). found: {$mail->className}</p>"; return; } if(!$mail->testConnection()) { // Connection not working: echo "<p>Couldn't connect to the SMTP server. Please check the {$mail->className} modules config settings!</p>"; return; } Following are a ...


      List of all options and features


      testConnection () - returns true on success, false on failures


      sendSingle ( true | false ) - default is false

      sendBulk ( true | false ) - default is false, Set this to true if you have lots of recipients (50+)


      to ($recipients) - one emailaddress or array with multiple emailaddresses

      cc ($recipients) - only available with mode sendSingle, one emailaddress or array with multiple emailaddresses

      bcc ($recipients) - one emailaddress or array with multiple emailaddresses

       
      from = 'person@example.com' - emailaddress, can be set in module config (called Sender Emailaddress) but it can be overwritten here

      fromName = 'Name Surname' - optional, can be set in module config (called Sender Name) but it can be overwritten here


      priority (3) - 1 = Highest | 2 = High | 3 = Normal | 4 = Low | 5 = Lowest

      dispositionNotification () or notification () - request a Disposition Notification


      subject ($subject) - subject of the message

      body ($textBody) - use this one alone to create and send plainText emailmessages

      bodyHTML ($htmlBody) - use this to create a Multipart Alternative Emailmessage (containing a HTML-Part and a Plaintext-Part as fallback)

      addSignature ( true | false ) - the default-behave is selectable in config screen, this can be overridden here
      (only available if a signature is defined in the config screen)

      attachment ($filename, $alternativeBasename = "") - add attachment file, optionally alternative basename


      send () - send the message(s) and return number of successful sent messages


      getResult () - returns a dump (array) with all recipients (to, cc, bcc) and settings you have selected with the message, the message subject and body, and lists of successfull addresses and failed addresses,


      logActivity ($logmessage) - you may log success if you want

      logError ($logmessage) - you may log warnings, too. - Errors are logged automaticaly
       
       
      useSentLog (true | false) - intended for usage with e.g. third party newsletter modules - tells the send() method to make usage of the sentLog-methods - the following three sentLog methods are hookable, e.g. if you don't want log into files you may provide your own storage, or add additional functionality here

      sentLogReset ()  - starts a new LogSession - Best usage would be interactively once when setting up a new Newsletter

      sentLogGet ()  - is called automaticly within the send() method - returns an array containing all previously used emailaddresses

      sentLogAdd ($emailaddress)  - is called automaticly within the send() method
       
      Changelog: https://github.com/horst-n/WireMailSmtp/blob/master/CHANGELOG.md
       
    • By ukyo
      Call ProcessWire API Functions Inside STRING
      Github Repo
      Current status : BETA
      Each called method must return string value !
      I added all functions, but not tested all. I focused page(), page()->render and field properties (label, description and notes). I also tested some basic pages() api calls.
      Your API calls must start with { and must end with }. For use multiple arguments inside functions, separate arguments with ~ char.
      NOTE If you pass directly arguments to api {page(title)}, this call will check for requestedApiCall()->get(arguments).
      USAGE
      processString(string, page, language); Get page title <?php $str = "You are here : {page:title}"; echo processString($str); ?> Get page children render result <?php $str = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<hr>{page:render:children}"; echo processString($str); ?> Get homepage title <?php $str = "You can visit our <a hre='{pages(1):url}'>{pages:get(1):title}</a>"; echo processString($str); ?> Get title field label, description or notes <?php $str = "Our title field properties are : label: {label(title)} - description: {description(title)} - notes: {notes(title)}"; echo processString($str); ?> Multiple examples <?php $str = " <ul class='uk-list uk-list-striped'> <li><b>01: GET FIELD LABEL</b> <code>&#123;label(title)&#125;</code> <b>RESULT :</b> <code>{label(title)}</code></li> <li><b>02: GET FIELD LABEL WITH PREFIX</b> <code>&#123;label(title~=> )&#125;</code> <b>RESULT :</b> <code>{label(title~=> )}</code></li> <li><b>03: GET FIELD LABEL WITH SUFFIX</b> <code>&#123;label(title~~ <=)&#125;</code> <b>RESULT :</b> <code>{label(title~~ <=)}</code></li> <li><b>04: GET FIELD DESCRIPTION</b> <code>&#123;description(title)&#125;</code> <b>RESULT :</b> <code>{description(title)}</code><br> <li><b>05: GET FIELD DESCRIPTION WITH PREFIX</b> <code>&#123;description(title~=> )&#125;</code> <b>RESULT :</b> <code>{description(title~=> )}</code></li> <li><b>06: GET FIELD DESCRIPTION WITH SUFFIX</b> <code>&#123;description(title~~ <=)&#125;</code> <b>RESULT :</b> <code>{description(title~~ <=)}</code></li> <li><b>07: GET FIELD NOTES</b> <code>&#123;notes(title)&#125;</code> <b>RESULT :</b> <code>{notes(title)}</code><br> <li><b>08: GET FIELD NOTES WITH PREFIX</b> <code>&#123;notes(title~=> )&#125;</code> <b>RESULT :</b> <code>{notes(title~=> )}</code></li> <li><b>09: GET FIELD NOTES WITH SUFFIX</b> <code>&#123;notes(title~~ <=)&#125;</code> <b>RESULT :</b> <code>{notes(title~~ <=)}</code></li> <li><b>10: GET PAGE TITLE</b> <code>&#123;page(title)&#125;</code> <b>RESULT :</b> <code>{page(title)}</code></li> <li><b>11: GET PAGE TITLE</b> <code>&#123;page:title&#125;</code> <b>RESULT :</b> <code>{page:title}</code></li> <li><b>12: GET PAGE RENDER TITLE</b> <code>&#123;page:render:title&#125;</code> <b>RESULT :</b> <code>{page:render:title}</code></li> <li><b>12: GET HOMEPAGE TITLE</b> <code>&#123;pages:get(template=home):title&#125;</code> <b>RESULT :</b> <code>{pages:get(template=home):title}</code></li> <li><b>13: GET HOMEPAGE TEMPLATE ID</b> <code>&#123;pages:get(template=home):template:id&#125;</code> <b>RESULT :</b> <code>{pages:get(template=home):template:id}</code></li> </ul> "; echo processString($str); ?>
    • By Robin S
      This module corrects a few things that I find awkward about the "Add New Template" workflow in the PW admin. I opened a wishlist topic a while back because it would good to resolve some of these things in the core, but this module is a stopgap for now.
      Originally I was going to share these as a few standalone hooks, but decided to bundle them together in a configurable module instead. This module should be considered alpha until it has gone through some more testing.
      Add Template Enhancements
      Adds some efficiency enhancements when adding or cloning templates via admin.

      Features
      Derive template label from name: if you like to give each of your templates a label then this feature can save some time. When one or more new templates are added in admin a label is derived automatically from the name. There are options for underscore/hyphen replacement and capitalisation of the label. Edit template after add: when adding only a single template, the template is automatically opened for editing after it is added. Copy field contexts when cloning: this copies the field contexts (a.k.a. overrides such as column width, label and description) from the source template to the new template when using the "Duplicate/clone this template?" feature on the Advanced tab. Copy field contexts when duplicating fields: this copies the field contexts if you select the "Duplicate fields used by another template" option when adding a new template. Usage
      Install the Add Template Enhancements module.
      Configure the module settings according to what suits you.
       
      https://github.com/Toutouwai/AddTemplateEnhancements
    • By AAD Web Team
      Hi,
      I've put in a support request (as a followup on an existing one) for this but it's nearly 10pm Ryan's time, so I thought I'd ask on here just in case someone can help...
      Yesterday we purchased ProDrafts, but I couldn't get the key to validate. Every time I hit submit on the module settings screen the key would be removed from the field I entered it in, and then it would complain about the missing value. I put in a support request and Ryan responded last night. It turned out it was because we're behind a proxy/firewall. He gave me a fix to get around that issue - some code to go into admin.php. I put that code in and saved admin.php, but now I can't even get into our admin anymore!
      (Just to clarify, I took the code back out and saved admin.php but that made no difference. It's definitely not the new code causing the error.)
      The errors relate to a lack of permission on the ProDrafts module (see attached screenshot). We do have a key, but evidently the code Ryan gave me to add the key in via admin.php isn't taking effect before the error is thrown...?
      I tried removing the ProDrafts directory from the modules directory, but that hasn't helped.
      Is there a hook I can put in somewhere to tell it not to load ProDrafts at all, or not check the permissions? Or is there some way to manually uninstall it from the file system?
      Thanks!
      Margaret

    • By DaveP
      I just made a textformatter module that allows you to insert dummy content (lorem ipsum style) in text fields via shortcodes.
      Usage is simple - just type for example [dc3] into a textarea with this textformatter applied (plain textarea or CKEditor) and it will be replaced at runtime by 3 paragraphs of dummy content. It can also be used to populate text fields (for headings etc) using e.g. [dc4w]. This will produce 4 words (rather than paragraphs) at runtime.
      The actual content comes from an included 'dummytext.txt' file containing 50 paragraphs of 'Lorem ipsum' from lipsum.com. The 50 paragraphs is arbitrary - it could be 10 or 100 or anything in between, and the contents of that file can be changed for your own filler text if you wish.
      The slightly clever bit is that for any given page, the same content will be returned for the same tag, but the more paragraphs available in 'dummytext.txt', the less likely it is that two pages will get the same content (very roughly speaking - it's actually based on the page ID) so content selection is determinate rather than random, even though only the tags are saved to the db.
      Update
      Tags now work like this -
      [dc3] - Show 3 paragraphs ([dc:3], [dc3p] & [dc:3p] all do the same). [dc3-6] - Show 3 to 6 paragraphs randomly per page load ([dc:3-6], [dc3-6p] & [dc:3-6p] all do the same). [dc3w] - Show 3 words ([dc:3w] does the same). [dc3-6w] - Show 3 to 6 words randomly per page load ([dc:3-6w] does the same). <End update on tags.>
      If you think it might be useful, you can download it from GitHub and give it a try.