Jump to content

Recommended Posts

Posted

Using the below code for outputting content from a page field it doesn't get the manual sort order from the backend. What am I doing wrong?

<?php foreach($page->my_page_field("category=1474, sort=sort") as $mpf) { ?>
...
<?php } ?>

 

Posted

Removing the selector from the loop it outputs the content on the correct manual sort order BUT I only need to output the content with the selector "category=1474".

<?php foreach($page->my_page_field as $mpf) { ?>
...
<?php } ?>

 

Posted

Can you please try this:

<?php

// get all pages in page field
$resultsAll = $page->my_page_field;

// filter
$resultsByCategory = $resultsAll->filter('category=1474');

// sort
$resultsSorted = $resultsByCategory->sort('sort');

foreach($resultsSorted as $result) {
	// whatever
};

 

Posted
2 hours ago, wbmnfktr said:

Can you please try this:


<?php

// get all pages in page field
$resultsAll = $page->my_page_field;

// filter
$resultsByCategory = $resultsAll->filter('category=1474');

// sort
$resultsSorted = $resultsByCategory->sort('sort');

foreach($resultsSorted as $result) {
	// whatever
};

 

It doesn't work. I guess this is not possible. I'll have to use "sort=name" or something similar.

Posted

Have you tried

<?php
// get all pages in page field sorted by manual sort order
$resultsAllSorted = $page->my_page_field->sort('sort');
// filter
$resultsCategory = $resultsAllSorted->filter('category=1474');
// loop
foreach($resultsCategory as $result) {
	// ...
}

?

Posted
23 minutes ago, gebeer said:

Have you tried


<?php
// get all pages in page field sorted by manual sort order
$resultsAllSorted = $page->my_page_field->sort('sort');
// filter
$resultsCategory = $resultsAllSorted->filter('category=1474');
// loop
foreach($resultsCategory as $result) {
	// ...
}

?

Yep, it doesn't work.

Posted

Ok... I don't have the exact same ProcessWire setup like you but sorting and filtering my page field's entries works with the example above.

Is there a detail we miss at this point?

 

Posted
9 hours ago, Zeka said:

@PWaddict What type of page field type you have set up in the settings? 

Page field value type: Multiple pages PageArray
Input field type: AsmSelect

I decided to output all content from the page field without using a selector. Thank you all for trying to help.

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