Jump to content
MadeMyDay

Module: PageTableExtended

Recommended Posts

Perhaps read the documentation first: http://processwire.com/api/fieldtypes/images/

As I said: If your image field is called "myImageField" (I actually don't know how you called it, you mix a lot of names up there ;) ) and is set to a single image, you have to wrap in an image tag: 

<img src='{$myImageField->url}' alt=''>

The code I posted originally was my template. That only fits if you name your fields likewise. This only should demonstrate how that thing works. Your fields are probably named different, so you have to adjust your templates.

Share this post


Link to post
Share on other sites

A small sidenote request:

I think it would be really great if you or someone else could supply eventually a basic set of demo templates for this module.

Nothing fancy, no css, just the proper php and markup with maybe a few comments where to put what.

Thanks for your consideration

Share this post


Link to post
Share on other sites

Nope, I used only my correct image field names.

I read about outputting images before and used this already extensively on a recent website.

Thanks to PW I already made friendship with include, echo, foreach, if, get, and quite a few more, but I saw nowhere a tutorial about using fieldnames in curly brackets  {$image_1->url}. Are these special module tags or just plain php?

Anyway, thanks for your input so far.

Maybe I'll start fresh all over in a few days and see if it gets better somehow.

Share this post


Link to post
Share on other sites
but I saw nowhere a tutorial about using fieldnames in curly brackets  {$image_1->url}. Are these special module tags or just plain php?

No, this is plain PHP. Since 5.3. I think and if short tags are activated in php.ini, which it is mostly. So <?php echo $var; ?> is the same as <?= $var ?>  is the same as echo "$var". Double quotes are necessary, echo '$var' won't work. The curly brackets are for encapsulating object references or functions. echo "$image->url" won't work, while echo "{$image->url}" will.

Share this post


Link to post
Share on other sites

I have a fresh install (PW 2.5.3) and wanted to try out this module (version 0.2.0, installed through ModulesManager), but I keep getting this error: 

Error: Call to a member function of() on a non-object (line 101 of /Volumes/schijf/Users/eelke/Documents/Werk/Server/vida/site/modules/FieldtypePageTableExtended/InputfieldPageTableExtended.module) 
This error message was shown because you are logged in as a Superuser. Error has been logged.

My configuration is really simple:

- Template "Slide"

- Field "title"

- Field "image" (single image field)

 

- Template "Home"

- Field "title"

- Field "slideshow" (PageTableExtended, set to select "Slide" templates)

 

- For testing purposes "Slideshow"'s Table fields has been set to just include the Title column

- No extra CSS / other templates location has been set

- A stand-alone page using Slide works fine

- When disabling the "Render Layout instead of table rows?" option everything works fine

This is the complete Slide template (no header/footer is added) :

<?=$page->title?><br>
<?=$page->image->url?>

(Expected behaviour here is of course not to see the image rendered, but to get the filename).

Share this post


Link to post
Share on other sites

Good news everyone, I figured out what's going on here.

My problem only occurred when there were no pages linked. 

I could bypass the problem by first adding a slide, and only after that turning on the Render Layout toggle. 

Turns out the problem lies on line 101 as per warning, as this bit is outside the foreach-loop that defines $parsedTemplate.

       $parsedTemplate->page->of(false); // set OutputFormatting back to false, just in case

Moving this line to line 90 (inside the foreach) fixed it. 

Share this post


Link to post
Share on other sites

MademyDay, this is a fantastic addition to the sytem, thanks for all your hard work.

Just a question, do you personally see this more as something where you'd try and fully replicate your front-end output or just a means of displaying things in the backend in a more pleasing way? (I guess answer is probably both...)

Share this post


Link to post
Share on other sites

Thx André.

Just a question, do you personally see this more as something where you'd try and fully replicate your front-end output or just a means of displaying things in the backend in a more pleasing way? (I guess answer is probably both...)

yep, both ;) My initial need for this was to have a possibility for clients to mix different layout templates. PageTable does exactly that while keeping the flexibility of normal templates. So the functionality was there but for not so tech-savvy clients it was too less visual. They want to see what they create. So this module was born. It is now your decision if you want an exact 1:1 copy of the frontend which results in more work but a nicer Interface or if you just want them to keep track of their edits/additions. I use the module in three sites at the moment (not public yet but one is shown in the video above). I generally wouldn't promise a 1:1 view of the frontend because clients then tend to "style" the content by themselves.  I have one client who always tries to fit the length of text lines in two columns. If the interface would kind of promise to be an 1:1 copy of the frontend (which it NEVER can be) it would be a false safety so I'd rather suggest to keep the layout model in this module but make no promises about exact styling.

  • Like 2

Share this post


Link to post
Share on other sites

Got a wee problem here.

If I use This in a template

<?php

if($options["pageTableExtended"]){

echo "<h3>{$page->headline}</h3>";

} else {

// load of other stuff

}

It is not rendering the headline field.

If I remove the IF then it works.

Turning debug mode on in the admin gives me:

Notice: :  Undefined index: pageTableExtended in /home/joss/public_html/site/templates/image.php  on line 3

What I do wrong?

Share this post


Link to post
Share on other sites

Hey Joss,

sorry, totally oversaw your posting. Could you give some more information (more code)? Not sure why the error is given in the image.php...

Share this post


Link to post
Share on other sites

Oh, damn - I am going to have to go back and look. I have been working on some D&B arrangements and got sidetracked (at my age too!)

Share this post


Link to post
Share on other sites

Okay, I have a template called image.php that is used for creating a page with a single image and things like description and a load of rubbish.

However, these pages are really there to make up a gallery using Page Table Extended - but they have their own template file so they can be seen outside of the gallery on the site. Nothing complicated.

The template had headers and footers and tons of rubbish that is no good for page table extended, so have I use your thing:

<?php

if($options["pageTableExtended"]){

/* The gallery images are used in a page table extended in admin.

We cant display those with all the head and foot!

So in this section we do an alternate markup

*/

echo "<h3>{$page->headline}</h3>";


} else {

/* Back to the normal markup */

include("./includes/head.inc");


include("./includes/scripts.inc");

include("./includes/foot.inc");

}

But, when I go and look at the page in the admin that used the page table extended field, it does not display the headline, but just the error as above. 

I haven't added all the other fields yet, I am keeping it simple just to get it working.

Boy, this rioja is good!

Share this post


Link to post
Share on other sites
Boy, this rioja is good!

Man, this Cabernet, too! And you are totally right. It obviously doesn't work with the current version. Seems I broke too much last time when merging stuff. Will take a look and report back (but not tonight, see first 4 words of this posting) :)

Share this post


Link to post
Share on other sites

Fair enough - I have, ummm, other things to do right now anyway....  :-[

Share this post


Link to post
Share on other sites

I also see that NOTICE. With using isset I got it go away. Not sure your switch still works with isset, I did not code the front end output yet.

By the way: what is the recommended way to output the content? 

I am really fallen in love with this extended module. I see the huge benefits. Very smart.

I want to use ist that way - like in the example movie - that the pagetable elements render as inluded "blocks". Like the repeater field did it.

masterpage

- block

- block

Do you have a code example? I am curious how $page works in that context (does it refers to masterpage or block)...

And how does the find work - does it find the masterpage if the searched for content is in a block?

(Too bad that there is no full example/tutorial online yet - I found only fragments of explanations spread all over the forum.)

Share this post


Link to post
Share on other sites

Update:

rendering is so easy I could not believe it. The code worked for me (in case anyone has the same question):

foreach ($page->my_pagetable as $block) {
$block->render();
}

Now I could see for myself:  isset makes the NOTICE go away but the clever switch trick from Joss does not work either. :(

EDIT:

This switch seems to work for now:

<?php if(strpos($_SERVER['REQUEST_URI'],wire('pages')->get(wire('config')->adminRootPageID)->url) !== false) : ?>

Credits to Nico

Share this post


Link to post
Share on other sites

I tried to update from 0.2.0 to 0.2.2 and have an issue: "Path to Templates" does not work as before.

I have a template directory "controllers/", which contains a template called "image-text.php". The "image-text.php" template has set "router.php" as alternative template name.

With 0.2.2, if I try to edit the page which has the pagetable field, I get the message

TemplateFile: Filename doesn't exist: [...]/site/templates/controller/router.php"

Sure, should be "[...]/site/templates/controller/image-text.php

If I comment out line 50 in 0.2.2 and insert

$parsedTemplate = new TemplateFile($this->config->paths->templates . $this->pathToTemplates  . $p->template->name . ".php");

(the line 50 from 0.2.0) all is well again.

Share this post


Link to post
Share on other sites

adrianmak,

Have you installed this and given it a try? It's fairly straightforward (and really cool). 

Share this post


Link to post
Share on other sites

First: thx for the great module, I can scrap my first attempt to something similar!

Second: are there any thoughts on adding an option to add an already existing 'page' to the PageTableExtended field in the admin.

Since I build a type of 're-usable widgets' for my client, they want to re-use already created 'pages', thus re-using content.

Right now you can only create new 'pages', or I missed something along the way? :-)

I might dive in myself and see if I can add that myself, if time will let me, but I wonder how many others might consider this a welcome addition?

And should that become a PageTableExtendedExtension or a new version of PageTableExtended

Share this post


Link to post
Share on other sites

First: thx for the great module, I can scrap my first attempt to something similar!

Second: are there any thoughts on adding an option to add an already existing 'page' to the PageTableExtended field in the admin.

Since I build a type of 're-usable widgets' for my client, they want to re-use already created 'pages', thus re-using content.

Right now you can only create new 'pages', or I missed something along the way? :-)

I might dive in myself and see if I can add that myself, if time will let me, but I wonder how many others might consider this a welcome addition?

And should that become a PageTableExtendedExtension or a new version of PageTableExtended

Have a read of this thread about the main PageTable field: https://processwire.com/talk/topic/8177-page-table-howto/

It is possible to automatically add existing pages if they are under the same parent. If they aren't then you can add them with a small bit of API code which Macrura shows in that thread.

Hope that helps!

Share this post


Link to post
Share on other sites

Hey,

the green buttons at the end of the Table: why theres not displaying the template-name (in your screenshot)?

I'd like to have something too, because users want to see something like "Text with to columns" instead of "layoutbox-text-columns_2".

How this works? Is there a solution in processwire, also for "Add New"-Elements.

Thank You!

qualtext

git1.jpg

Edited by Qualtext

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild.  
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Steps (Read more) Manual override of the selected value (will still adhere to the rules above) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant If it's usable for others I'll add it to the Modules list  
      Changelog
      v002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional 
      v001
      - Initial release
       
      Thanks!
       
       
    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
    • By adrian
      This module allows you to automatically rename file (including image) uploads according to a configurable format
      This module lets you define as many rules as you need to determine how uploaded files will be named and you can have different rules for different pages, templates, fields, and file extensions, or one rule for all uploads. Renaming works for files uploaded via the admin interface and also via the API, including images added from remote URLs.   Github: https://github.com/adrianbj/CustomUploadNames
      Modules Directory: http://modules.processwire.com/modules/process-custom-upload-names/
      Renaming Rules
      The module config allows you to set an unlimited number of Rename Rules. You can define rules to specific fields, templates, pages, and file extensions. If a rule option is left blank, the rule with be applied to all fields/templates/pages/extensions. Leave Filename Format blank to prevent renaming for a specific field/template/page combo, overriding a more general rule. Rules are processed in order, so put more specific rules before more general ones. You can drag to change the order of rules as needed. The following variables can be used in the filename format: $page, $template, $field, and $file. For some of these (eg. $field->description), if they haven't been filled out and saved prior to uploading the image, renaming won't occur on upload, but will happen on page save (could be an issue if image has already been inserted into RTE/HTML field before page save). Some examples: $page->title mysite-{$template->name}-images $field->label $file->description {$page->name}-{$file->filesize}-kb prefix-[Y-m-d_H-i-s]-suffix (anything inside square brackets is is considered to be a PHP date format for the current date/time) randstring[n] (where n is the number of characters you want in the string) ### (custom number mask, eg. 001 if more than one image with same name on a page. This is an enhanced version of the automatic addition of numbers if required) If 'Rename on Save' is checked files will be renamed again each time a page is saved (admin or front-end via API). WARNING: this setting will break any direct links to the old filename, which is particularly relevant for images inserted into RTE/HTML fields. The Filename Format can be defined using plain text and PW $page variable, for example: mysite-{$page->path} You can preserve the uploaded filename for certain rules. This will allow you to set a general renaming rule for your entire site, but then add a rule for a specific page/template/field that does not rename the uploaded file. Just simply build the rule, but leave the Filename Format field empty. You can specify an optional character limit (to nearest whole word) for the length of the filename - useful if you are using $page->path, $path->name etc and have very long page names - eg. news articles, publication titles etc. NOTE - if you are using ProcessWire's webp features, be sure to use the useSrcExt because if you have jpg and png files on the same page and your rename rules result in the same name, you need to maintain the src extension so they are kept as separate files.
      $config->webpOptions = array(     'useSrcExt' => false, // Use source file extension in webp filename? (file.jpg.webp rather than file.webp) ); Acknowledgments
      The module config settings make use of code from Pete's EmailToPage module and the renaming function is based on this code from Ryan: http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/?p=32623 (also see this post for his thoughts on file renaming and why it is the lazy way out - worth a read before deciding to use this module). 
       
       
      NOTE:
      This should not be needed on most sites, but I work with lots of sites that host PDFs and photos/vectors that are available for download and I have always renamed the files on upload because clients will often upload files with horrible meaningless filenames like:
      Final ReportV6 web version for John Feb 23.PDF

×
×
  • Create New...