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 gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...