Jump to content
MadeMyDay

Module: PageTableExtended

Recommended Posts

You have to define the title field globally as not required (field settings). Otherwise the page doesn't get published. What PageTable (and so also the extended version) does, is to display the autoformat title instead of the title field. The field itself remains required as long as you don't define it otherwise.

Would you also can try to do (haven't tried it myself yet): Define the field as not global, so you don't need to add it to your PageTable templates.

Share this post


Link to post
Share on other sites

Just to add to the confusion.

- You can make the title field not required in template context.

- You can set a template to not include global fields (advanced settings) So you could remove title for that template but still have title global.

  • Like 7

Share this post


Link to post
Share on other sites

Just to add to the confusion.

- You can make the title field not required in template context.

- You can set a template to not include global fields (advanced settings) So you could remove title for that template but still have title global.

So this seems to be the safest way, thx Soma!

Share this post


Link to post
Share on other sites

@MadeMyDay, unchecking the Global box on the title field worked. @Soma's advice also worked. I unchecked "Required" for the template's title and changed the "Visibility" to hidden. Worked like a charm. Thank you!

Share this post


Link to post
Share on other sites

Really awesome module, MadeMyDay!

I'm using some kind of template delegate approach (template has an alternative template filename set - "router.php" - which controls the inclusion of the "real" templates in a MVC way. These templates reside in subfolder "controllers".) In order to make it work, I had to change line 45 from

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

to

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

Maybe you have a better idea for people like me who use alternative template paths? Using my way, I always have to manually update the module file, if it get's updated by you.

Another question: how does the module deal with unpublished PageTable (sub)pages (the "blocks" inside the PageTable)? They are not handled different to published pages, are they? I think I would like to get them rendered with an extra css class around it - this way the content could be especially marked or hidden by CSS. (I guess this could also be done on template level, but it's not convenient that much.)

  • Like 1

Share this post


Link to post
Share on other sites
Maybe you have a better idea for people like me who use alternative template paths? Using my way, I always have to manually update the module file, if it get's updated by you.

Will make the path configurable.

Another question: how does the module deal with unpublished PageTable (sub)pages (the "blocks" inside the PageTable)? They are not handled different to published pages, are they? I think I would like to get them rendered with an extra css class around it - this way the content could be especially marked or hidden by CSS. (I guess this could also be done on template level, but it's not convenient that much.)

I have an idea, will implement it asap. How does this sound: Additional CSS classes for unpublished, hidden, locked. And additionally a setting if unpublished blocks should be rendered collapsed or if all blocks always should be open.

Share this post


Link to post
Share on other sites

Pushed an update to the module:

New settings:

Path to Templates

If you use a delegated template approach, please provide your path to the templates (relative to templates directory).

Collapse unpublished rows

If checked, unpublished PageTable parts are rendered collapsed and can be opened on click.

(hidden) CSS classes for PageTable page status

The rendered parts (the div.renderedLayout) get the status of the page as CSS class:

  • ".pte-hidden" for hidden pages
  • ".pte-unpublished" for unpublished pages
  • ".pte-locked" for locked pages

@titanium: Could you please test the new version (0.2.0.) with your template delegate approach. I don't use it, so I can't test it quickly. But should work ;)

  • Like 7

Share this post


Link to post
Share on other sites

@titanium: Could you please test the new version (0.2.0.) with your template delegate approach. I don't use it, so I can't test it quickly. But should work ;)

You're welcome! I did test it, and it works great! Only one small glitch - one of the help text says: "For example "/controllers/"". I think it should be corrected to "For example "controllers/", because the first front slash is already part of $this->config->paths->templates.

This module contributes great value to ProcessWire and I nominate it as Module Of The Year  :)

Share this post


Link to post
Share on other sites
Only one small glitch - one of the help text says: "For example "/controllers/"". I think it should be corrected to "For example "controllers/", because the first front slash is already part of $this->config->paths->templates.

fixed, thx.

This module contributes great value to ProcessWire and I nominate it as Module Of The Year   :)

And I nominate PageTable itself, without that it wouldn't be possible ;) But thank you very much :)

Share this post


Link to post
Share on other sites

Just to add to the confusion.

- You can set a template to not include global fields (advanced settings) So you could remove title for that template but still have title global.

Really?

I have a template called 'options' but I can't find that in the 'advanced' tab [using 2.5.1 dev]

Share this post


Link to post
Share on other sites

It looks like that OutputFormatting is off when you open a page with that contains a PageTableExtended field. After editing a 'page' and closing the modal, OutputFormatting kicks in and the page renders as expected. Is there a way to enable OutputFormatting right away? 


Oké, I should not complain :-) When I add OutputFormatting to the page at line at line 52 it looks like it resolves the issue:

//InputfieldPageTableExtended.module
$parsedTemplate->page->of(true);
(Made a pull request on github) Edited by Martijn Geerts

Share this post


Link to post
Share on other sites

I'd gladly accept the pull request. But I totally don't understand why output formatting is off in the first place. Some general admin thing? Would make sense, but then I think it wouldn't be the best idea to simply turn it on. Perhaps there is a reason for setting it to off? Does anyone know why?

Btw: I am thinking of building a version where the rows get rendered in an Iframe (pretty much like Form Builder does), so we have a more sandboxed solution. Not quite sure about the additional work needed though.

  • Like 1

Share this post


Link to post
Share on other sites

I'd gladly accept the pull request. But I totally don't understand why output formatting is off in the first place. Some general admin thing? Would make sense, but then I think it wouldn't be the best idea to simply turn it on. Perhaps there is a reason for setting it to off? Does anyone know why?

Adrian noticed the same thing recently.

  • Like 1

Share this post


Link to post
Share on other sites

Actually, you don't turn it on for the admin, but for the specific page getting rendered. Untill now I don't see any negative side effects.

Share this post


Link to post
Share on other sites

I just merged the two PRs, don't see any side effects. But decided to turn off of after rendering just in case... ;)

(btw: I think I didn't procede the PRs correctly, merged a lot in circles, sorry for that :) )

Share this post


Link to post
Share on other sites

Output formatting is off because we are in the back-end. Pages loaded in any a module have it off, it's only on in front-end context. All normal, and no problem turning it on if needed.

  • Like 3

Share this post


Link to post
Share on other sites

Hi,

first of all thanks for this great module.

Unfortunately I can't get it to work as expected.

I must admit that I just recently built my first website with pw and I haven`t even had a look at how the PageTable Module works.

I use PW 2.5.3 dev and I installed PageTable and PageTableExtended modules.

I created two templates with template files that contain the part template code from MadeMyDay on page one of this thread (plus my fields):

<?php
$headline1 = "";
$headline2 = "";
if(!$page->checkbox1) $headline1 = "<h2>{$page->title}</h2>";
if(!$page->checkbox2) $headline2 = "<h2>{$page->text1}</h2>";
// Output
echo "
<div class='pageTableSection {$page->template->name}'>
    <div class='inner'>
        <div class='col one-half'>
                {$headline1}
                {$page->body}
                {$image_1} // my image field 1
                {$textblock_1} // my text field
         </div>
        <div class='col one-half'>
            {$headline2}
            {$page->textarea1}
            {$image_2} // my image field 2
            {$textblock_1} // my text field
        </div>
    </div>
</div>
";

Then I created one image field and one Textfield and assigned them to my part templates.

After this I created one PageTableExtendedField and selected my 2 part templates under the details tab and title,
Image_1 and textblock_1 under the Input tab as table fields to display in admin.
I checked: Render Layout instead of table rows
I didn't put any stylesheet yet.

In my basic-page.php I pasted this part:

<?php
$bodyclass='inner';
$content = "{$page->body}";
if(count($page->layout)>0){
     foreach($page->layout as $l){
         $content .= $l->render();
     }
}

What I am getting now in the backend is an error:

Error: Call to a member function of() on a non-object (line 101 of /home/home1007/public_html/pw/site/modules/FieldtypePageTableExtended/InputfieldPageTableExtended.module)

I outcommented line 101:

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

Now I saw my part_templates as two buttons only in the backend.

pw1.png

After I expanded them I could enter title and name. I did this and then I was also able to enter an image and some text.

Now it looks like this, both fields have an image, and some text, but in the layout elements only the titles are displayed:

pw2.png

Only when I press the edit button on the right side, I can see my image and my Text.

Also the two buttons remain on the bottom. (Don't know if this should look like this)

Obviously I did something wrong, but I couldn't find any more precise instruction for either PageTable or PageTableExtended.

Please bear with me, I still got a lot to learn and I would be very happy if someone could tell what I did wrong or what I have to do more to set set this up properly.

Regards, Thomas

Share this post


Link to post
Share on other sites

Sorry, I am in a hurry, but two things:

{$image_1} // my image field 1

should be 

{$image_1->url} // my image field 1
Also the two buttons remain on the bottom. (Don't know if this should look like this)

Yes, the buttons are always at the bottom (like in PageTable itself).

Because of the backend error you got first: I have to take a deeper look.

Thx for reporting!

Share this post


Link to post
Share on other sites

@mademyday: Thanks for your help

I changed my code to:

{$image_1->url} // my image field 1

still my images are not visible in the layout elements. :mellow:

But I just realized that I could revert InputfieldPageTableExtended.module to it's original state without getting an error.

(And it had nothing to do with my false image call)

I really don't know what I did to make the error dissapear, but it's gone. :rolleyes:

Share this post


Link to post
Share on other sites

Sorry, my fault. By default the image object returns an array of images, so if you want to have the url of the first image you have to do this:

{$image_1->eq(0)->url} // my image field 1
I really don't know what I did to make the error dissapear, but it's gone. 

I assume you got this error while there wasn't any template to be rendered or you got an error which prevented the template from being rendered and then caused this follow-up error.

Share this post


Link to post
Share on other sites

hhm, that gives me an Error:

Error: Call to a member function eq() on a non-object (line 17 of /home/home1007/public_html/pw/site/templates/part_tpl_1.php)

Share this post


Link to post
Share on other sites

Well, it depends on how you configured the image field. If it is set to hold multiple images you get the url of the first image with:

$myImageField->eq(0)->url

Otherwise, if you set the image object to only allow one image, then you get the url of the image like this:

$myImageField->url

Either way, this just the url. For outputting the image in the template you have to wrap it in an image tag like so:

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

Share this post


Link to post
Share on other sites

Sorry, but I think I did that right.

Well now I allowed only one image in my image field and keep using

$myImageField->url

at least I have no errors.

Do I maybe have to put the image url in a variable?

<?php
$headline1 = "";
$headline2 = "";
$image = $image_1->url; //my trial with a variable didn't work

if(!$page->checkbox1) $headline1 = "<h2>{$page->title}</h2>";
if(!$page->checkbox2) $headline2 = "<h2>{$page->text1}</h2>";

echo "
<div class='pageTableSection {$page->template->name}'>
    <div class='inner'>
        <div class='col one-half'>
                {$headline1}
                {$page->body}
                {$image} // before trying the variable thing I had here: {$image_1->url;}
                {$textblock_1}
         </div>
       </div>
</div>
";

Anyhow, from this code with or without the commented changes I am getting this markup in my layout field in the admin:

<div class="pageTableSection part_tpl_1">
                        <div class="inner">
                            <div class="col one-half">
                                    <h2>wtf</h2>
                                 
                                
                            </div>
                        </div>
</div>

Only {headline} gets outputted.

Guess I am doing something really wrong here. :mellow:

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...