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

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 joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.1.1 Debugging: fixed error during uninstall 0.1.0 Added new detection of async scripts for W3C Validation 0.0.6 CSS-Debugging for hiding unused buttons, added ProCache support for the JavaScript tag 0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • 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!
×
×
  • Create New...