Jump to content

Module: PageTableExtended


MadeMyDay

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.

Link to comment
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
Link to comment
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!

Link to comment
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
Link to comment
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.

Link to comment
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
Link to comment
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  :)

Link to comment
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 :)

Link to comment
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]

Link to comment
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
Link to comment
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
Link to comment
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

Link to comment
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!

Link to comment
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:

Link to comment
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.

Link to comment
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
Link to comment
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:

Link to comment
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
×
×
  • Create New...