Jump to content

Module: PageTableExtended


MadeMyDay

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.

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

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

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

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

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

Link to comment
Share on other sites

  • 2 weeks later...

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

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

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

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

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

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

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

  • 2 months later...

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

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

Link to comment
Share on other sites

  • 3 weeks later...

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