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

Please grab a new copy / checkout the branch again. Or just delete line 101, it made more trouble than had benefits ;)

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

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
    • By MoritzLost
      Sorry for the convoluted title. I have a problem with Process modules that define a custom page using the page key through getModuleInfo (as demonstrated in this excellent tutorial by @bernhard). Those pages are created automatically when the module is installed. The problem is that the title of the page only gets set in the current language. That's not a problem if the current language (language of the superuser who is installing the module) is the default language; if it isn't, the Process page is missing a title in the default language. This has the very awkward effect that a user using the backend in the default language (or any other language) will see an empty entry in the setup menu:

      This screenshot comes from my Cache Control module which includes a Process page. Now I realize the description sounds obscure, but for us it's a common setup: We a multiple bilingual sites where the default language is German and the second language is English. While the clients use the CMS in German, as a developer I prefer the English interface, so whenever I install a Process module I get this problem.
      As a module author, is there a way to handle this situation? I guess it would be possible to use post-installation hooks or create the pages manually, but I very much prefer the declarative approach. The page title is already translatable (through the __ function), but of course at the time of installation there is no translation, and as far as I'm aware it's not possible to ship translations with a module so they are used automatically. Could this situation be handled better in the core? I would prefer if the module installation process would always set the title of the Process page in the default language, instead of the language of the current user.
×
×
  • Create New...