Jump to content

Module: PageTableExtended


MadeMyDay

Recommended Posts

Just use the labels of templates to name them more descriptively. The buttons below pagetables will always show the label and fall back to the name of the template if no label is defined.

For the "add new" buttons, there are a lot of them in processwire. Most of them are there, because either the context provides the information about what will be added or the cms can not tell ahead of time what will be added. You can edit them with hooks, different ones dependent on which one you'll want to edit, but not via the admin backend. But this is not the thread to take about this in detail.

  • Like 1
Link to comment
Share on other sites

Just use the labels of templates to name them more descriptively. The buttons below pagetables will always show the label and fall back to the name of the template if no label is defined.

Labels! This Label-Field in Template was never catching my Eye.

Thank you.

Link to comment
Share on other sites

  • 1 month later...

git2.jpg

From the screenshot, there are three different page content, Text block with headline, text columns and image gallery could be added.

How to do something like that with this module?

Edited by kongondo
Edited for clarity
Link to comment
Share on other sites

  • 1 month later...

Hi,

I'm using this module to display some different sections on the homepage of a webseite like in this example: https://processwire.com/talk/topic/7459-module-pagetableextended/#entry71793

My home template file looks like this:

$page = $pages->get(1021); // This is a Site for storing all sections of the homepage

foreach($page->children as $child) {
	require($child->template .'.php');
};

$mainContent = $out;

Here's an example of one of my child-templates:

<?php 

/* section-slider.php  - Template File for a Slider*/

// Check if Back- or Frontend

if(isset($options['pageTableExtended'])){
    $useMain = false;
    $out = "";
    $addJS = "";
}

// Check if is in frontend	
else {
    $page = $child;
};

// Starting output

$images = $page->images;

$mini =   320;
$small =  640;
$medium = 900;
$large =  1200;
$xlarge = 1680;

$out .= "

	<section id='{$page->name}' class='slides'>";
		
		foreach($images as $img) {			
			$out .= "<img src='{$img->width($mini)->url}' srcset='{$img->width($mini)} {$mini}w, {$img->width($small)} {$small}w, {$img->width($medium)->url} {$medium}w, {$img->width($large)->url} {$large}w, {$img->width($xlarge)->url} {$xlarge}w' alt='{$img->description}'>";
		};
		
$out .= "
	</section>";

// Load JS and CSS Files

$inlineJS .= "
	<script>
		$(function() {
			$('.slides').slidesjs({
				width: 1200,
				height: 900,
				navigation: {
					effect: 'fade'
				},
				pagination: {
					effect: 'fade'
				},
				effect: {
					fade: {
						speed: 3000
					}
				},
				play: {
					active:true,
					auto: true,
					swap: false,
					effect: 'fade',
					pauseOnHover: false,
					interval: 5000
				}
			});
		});
	</script>";

array_push($cssFiles,"css/slides.css");
array_push($jsFiles,"js/jquery.slides.min.js");
	
// Check if backend

if(isset($options['pageTableExtended'])){
    echo($out);
}

Two questions:

1. I'm wondering if it's possible to redirect the children of the site to the parent-site or to the homepage, when a user tries to visit the childpage directly, so that it's not possible to visit the child-page directly.

2. How are the child-pages sorted? When I try to sort them via drag&drop here:

post-889-0-31901100-1433844880_thumb.jpg

this don't effect the frontpage.

I've to sort the child-pages to get the correct sortorder here:

post-889-0-02600700-1433845111_thumb.jpg

Where can I change it, so that the childpages are sorted correctly?

Many greets, DV-JF alias Jens.

Link to comment
Share on other sites

1. I'm wondering if it's possible to redirect the children of the site to the parent-site or to the homepage, when a user tries to visit the childpage directly, so that it's not possible to visit the child-page directly.

2. How are the child-pages sorted? When I try to sort them via drag&drop here:

1. Something like this should work:

if($page->url ===  $_SERVER['REQUEST_URI']) {
	$session->redirect($page->parent->url);
}

2. How are the child-pages sorted? When I try to sort them via drag&drop here:

2. From https://processwire.com/api/selectors/

foreach($page->children('sort=sort') as $child) {
	require($child->template .'.php');
};
Link to comment
Share on other sites

  • 1 month later...
  • 6 months later...
  • 2 months later...

I am trying to understand if I should use the new ProFields Repeater Matrix or PageTableExtended. Does PageTableExtended have any distinct benefits? I haven't had a chance to test thoroughly enough to make the decision yet.

Link to comment
Share on other sites

I haven't tested the new matrix field for now.

PTE renders the selected templates/blocks for the editor. So the dev could create a simple visual blockeditor with drag and drop the blocks and prerender them like it looks on frontend or in a other way that fits in the backend like teammembers, slideimages and so on.

Some things to mention:

- Care for the used templates to render in SEO things - access the single parts are possible if you don't handle this (for example you have all PTE elements under a hidden parent the elements are accessable on frontend, too)

- The CSS for prerendering is sometimes a little tricky since it could be that it crashes with the admin styles (only some special classes and maybe fontsizes and so on)

  you could use .renderedLayout Class on such elements in your special CSS file for PTE.

I'm running PTE for pretty much every repeating element that is more complex like contentblocks, sliderimages with text and settings, teammembers, grouping documents and so on...all things that elements in summary are under a rage from 10 to maximum 40. If i need more elements like events or something i'll stick to pages.

best regards mr-fan

  • Like 4
Link to comment
Share on other sites

  • 5 weeks later...
  • 3 months later...
  • 1 month later...

@MadeMyDay

Looking forward indeed! Such an amazing module.
Running smoothly on ProcessWire 3.0.30 devns here btw.

One small quibble: How would you get the sort order from the drag and drop view of the module to correlate to the child pages in the tree view? As Jens pointed out, it seems there is currently no possibility to sync these two up or render/access the module's custom sort order?

Cheers!
Phil

Link to comment
Share on other sites

1 hour ago, phil_s said:

One small quibble: How would you get the sort order from the drag and drop view of the module to correlate to the child pages in the tree view?

Just wondering why you would need to do this. A PageTable field does not necessarily include all the children of a given parent so the contents/order of the field could never match the children in all circumstances. I would have thought that if you create a PageTable field then you interact with its pages via the field (whether we're talking about the API or the admin interface) rather than the page tree. Personally, I always store my PageTable pages under the admin branch so they're not visible/confusing for clients.

  • Like 2
Link to comment
Share on other sites

8 hours ago, Robin S said:
10 hours ago, phil_s said:

One small quibble: How would you get the sort order from the drag and drop view of the module to correlate to the child pages in the tree view?

Just wondering why you would need to do this...

I use PTE as a visual editor for modular layout blocks in a project page template of a Portfolio website. The client can create and arrange blocks with various configurations to build the individual project pages. The blocks will get added as children of the project page. The page tree thus looks something like this:

home
+ projects
  + first project
    + block-fullwidth
    + block-fullwidth
  + second project
    + block-twohalves
    + block-fullwidth
    ...

In theory the obvious benefit of using PTE here is that the client can do all the arranging (which is more of a try this and that process) directly in the interface, and preview which order they will appear in the page in in a visual way. 

In practice though, when I fill the array and specify a sort order for rendering like this:

 $blocks = $page->children('sort=sort')

..this will render the (manual) sort order from the page tree, not the manual sort order arranged by the client via the PTE interface.
I can rearrange the blocks in both views individually and access the page tree custom sort order e.g. via the above–but can't access PTE's sort order.

So TLDR: I would like to access and render the custom sort order done via the PTE fields, not a custom sort order done via the page tree. 
Am I looking at this the wrong way or missing anything? Should I fill the array with find/get instead?

Cheers guys!

Screen Shot 2016-09-08 at 14.26.44.jpg

Link to comment
Share on other sites

You don't have to refer to the page tree order or use $page->children. Assuming your PTE field is called "layout"  all you have to do is:

 

foreach($page->layout as $l){
    $layout .= $l->render();
}

The field itself holds the connection to its blocks. No matter where they are in the tree (because that's configurable).

  • Like 1
Link to comment
Share on other sites

1 hour ago, MadeMyDay said:

You don't have to refer to the page tree order or use $page->children. Assuming your PTE field is called "layout"  all you have to do is:

 


foreach($page->layout as $l){
    $layout .= $l->render();
}

The field itself holds the connection to its blocks. No matter where they are in the tree (because that's configurable).

Oh, nice :)

It seems reading the manual helps as usual. Sorry.

@Robin S How do you keep order without the context of the parent? (assuming you are using PTE for a similar setup)?

Thanks a bunch guys!

Link to comment
Share on other sites

8 hours ago, phil_s said:

How do you keep order without the context of the parent?

I'm not sure what you mean. It's just as @MadeMyDay explained - the order is stored as part of the field. You just need to get the "block" pages via the field rather than as children of a parent.

Instead of...

$blocks = $page->children('sort=sort');

...do...

$blocks = $page->my_pagetable_field;

 

  • Like 2
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...