Jump to content

Issue With Page Field Displaying The Title (Multiple Pages (Page Array))


cstevensjr
 Share

Recommended Posts

I have been transitioning to Page Table from Repeaters for quite some time.  I never had a problem with this transition.  A few weeks ago, I finally figured out how to display a Page Table on the front end of my websites.  Everything worked great.  I believe after upgrading to PW 2.6.2 (not quite sure) when I did the next Page Table I could not get my Page Fields to display any more.

I normally have an "Updates" Page Table that is made up of 3 parts (Date Field, TextArea Field and a Page Field).  Today I created a new installation that had minimal modules and went about structuring my site.  When I got to the "Updates" Page Table, it still would not display the "Contacts" title information.

The field is setup as indicated:

post-756-0-84540700-1436115543_thumb.png

My Contact fields allow for more than 1 person to be listed in the entry.

The following is a screenshot of what I have been getting for over 3 weeks.

post-756-0-42949300-1436115807_thumb.png

Next I added the "Contacts" Page Field directly to the template and changed the _main.php template file to display the field.

$cshcon = $page->crms_show_contact->title;

echo $cshcon;

 I still could not get the Title to display on the Page Field.  I finally ended up changing the setting for the field as follows:

post-756-0-72623900-1436115969_thumb.png

Once I did that, I could get the title to display as it should

post-756-0-15913500-1436116027_thumb.png

Either one of the singular settings worked.  It worked on the singular Page Field, as well as on the Page Table.  As soon as I changed the field setting back to Multiple Pages, it disappeared again.

What caused me the most pain was that whenever I would let the Page Table display the field without the title syntax it would display with the correct Page ID of the particular Page Field.

post-756-0-48008000-1436116498_thumb.png

Github issue opened which references this post

UPDATE:  I was remiss to not include the foreach information:  Thanks, tpr for bringing it to my attention.  It's been a long day already.

$csu = $pages->find("template=crms-updates, crms_status_updates=$page, sort=-crms_start_date");

if ($csu) foreach($page->crms_status_updates as $csu) {
            echo "<strong>{$csu->crms_start_date}</strong>  |";
            echo "  {$csu->crms_comments}  |";
            echo "  {$csu->crms_show_contact->title}";
            echo nl2br("<br />");
           }
Edited by cstevensjr
Updated to show the original foreach loop in _main.php
Link to comment
Share on other sites

If you set the field to be multiple then you should get its values as a (PageArray), that is, using a foreach loop. Your example doesn't tell if you are using a loop or not.

  • Like 1
Link to comment
Share on other sites

I meant another foreach loop.

$csu = $pages->find("template=crms-updates, crms_status_updates=$page, sort=-crms_start_date");

if ($csu) foreach($page->crms_status_updates as $csu) {
	echo "<strong>{$csu->crms_start_date}</strong>  |";
	echo "  {$csu->crms_comments}  |";
	
	// handle multiple page titles
	foreach($csu->crms_show_contact as $csu_page) {
		echo "  {$csu_page->title}";
	}
	
	echo nl2br("<br />");
}

(ps. I recommend leaving the styling part to the CSS (and remove  -es from php)

  • Like 1
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
 Share

×
×
  • Create New...