Jump to content

JerryDi

Members
  • Posts

    30
  • Joined

  • Last visited

Everything posted by JerryDi

  1. Thank you everyone, your help is much appreciated. It is working now apart from one of the columns [venue] where I have an if / else statement. I will look into that later. Jerry
  2. I've used your syntax but it's produced error messages again: Notice: Undefined variable: countymatch in /home/w5j4zigjq498/public_html/processwire/site/templates/year-summary.php on line 176 Warning: Invalid argument supplied for foreach() in /home/w5j4zigjq498/public_html/processwire/site/templates/year-summary.php on line 176 line 176 is: <?php foreach($countymatch as $match): ?>
  3. This is my code that attempts to output results to a table: <table border=1> <thead> <tr> <th>Opponents</th> <th>Venue</th> <th>Points for</th> <th>Points against</th> <th>Result</th> </tr> </thead> <?php $countymatch = $pages->find("template=county-match-result, year={$page->title} "); ?> <tbody> <tr> <?php foreach($countymatch as $match) ?> <td><?php echo "<a href='$match->url'> {$match->title}</a>"; ?></td> <td> <?php if ($match->home_away->title == 'Home'){ echo $match->home_match_venue->title("<a href='{url}'>{title}</a>"); } else{ echo $match->away_match_venue; }; ?> </td> <td><?php echo $match->cheshire_points; ?></td> <td><?php echo $match->opponent_points; ?></td> <td><?php echo $match->match_result->title; ?></td> </tr> </tbody> </table> and this is the code which I used to output to a list. This delivers all 11 matches perfectly, whereas I only get one with the table code <?php $countymatch = $pages->find("template=county-match-result, year={$page->title}"); foreach($countymatch as $match) { echo "<li><a href='$match->url'> $match->title</a></li>"; } ?>
  4. Thank you for your replies. The Year field is not a page reference, it is a simple text field. I get the same result on any year I choose to look at ie just one row is returned. Changing the find to year=2023 produces the same result ie a single row. If I use the same find and output the page titles to a list it works fine and delivers all the matches played in a given year. So my logic tells me it must be something to do with the foreach loop, but I really don't know what the issue is. Any thoughts would be much appreciated Thanks again Jerry
  5. Thank you. The counter returned a zero, despite me seeing one row in the table. I tested it on various viewed pages and I also get a single row returned on these DA2 had said that there is something missing in the loop, but I just don't know what may be.
  6. Thanks for your suggestion. I have tried this but it does not return any data in the table. Is there a different way to do this [my php knowledge is minimal]? many thanks
  7. I've made some progress with this. It now renders one line but there should be 9 rows: This is my code: <?php $countymatch = $pages->find("template=county-match-result, year={$page->id} "); ?> <tbody> <tr> <?php foreach($countymatch as $match) ?> <td><?php echo "<a href='$match->url'> $match->title - {$match->title}</a>"; ?></td> <td> <?php if ($match->home_away->title == 'Home'){ echo $match->home_match_venue->title("<a href='{url}'>{title}</a>"); } else{ echo $match->away_match_venue; }; ?> </td> <td><?php echo $match->cheshire_points; ?></td> <td><?php echo $match->opponent_points; ?></td> <td><?php echo $match->match_result->title; ?></td> </tr> </tbody> </table> I've tried various other ways to do this with no success. I'd very much appreciate some direction. Thanks
  8. It's simply a list of matches played in a given year, showing the fields you can see inside the table tags. The number of matches played in a year will vary.
  9. Hi, do I need to specify the fields required? Apologies, I am a php novice so would appreciate a pointer on what to do here Many thanks J
  10. Thanks. I have checked and my table HTML is valid. So the remaining problem is the foreach loop. What I am doing is retrieving the page for matches played in the year. I then want to have rows displaying opponents, venue, points for, points against and result. All of these fields are in the same template. Could you give me some guidance on how to construct the correct loop? many thanks Jerry
  11. Hi, I am trying to present selected fields from a single template in a simple HTML table. Here is my code: <?php $countymatch = $pages->find("template=county-match-result, year={$page->id}"); ?> <table> <strong> <tr> <th>Opponents</th> <th>Venue</th> <th>Points for</th> <th>Points against</th> <th>Result</th> </strong> </tr> <tr> <?php foreach($countymatch as $match): ?> <td><?php echo "<a href='$match->url'> $match->title - {$match->title}</a>"; ?></td> <td><?php if ($match->home_away->title = 'Home'){ echo $match->home_match_venue("<a href='{url}'>{title}</a>"); } else{ echo $match->away_match_venue; }; ?></td> <td><?php echo $match->cheshire_points; ?></td> <td><?php echo $match->opponent_points; ?></td> <td><?php echo $match->match_result->title; ?></td> </tr> <?php endforeach; ?> </table> All I get when I run this is the header row. I know the contents of each column work as I've run these outside of a table. Any suggestions would be much appreciated Thanks Jerry
  12. Actually some competitions are for pairs, so multiple is required thanks
  13. yes!!! Thank you, this works now You've been v helpful, thanks so much 😀
  14. Have tried this: echo("<pre>" . print_r($championship->winner_name, true) . "</pre>"); exit(); and the output is as attached When I tried this: echo gettype($championship->winner_name); I just got the word "object". So I tried echo gettype($championship->winner_name->title); and this produced "NULL"
  15. Here they are...the player screen grab only shows part of the page thank you
  16. Unfortunately using name does not work Is the issue here that this string is trying to select from a different template than the primary find?
  17. as per previous post, when I add ->title as per your post above, the page ID then disappears and I get just this: County Championship 1995 A bit baffling....
  18. <?php $playerChampionships = $pages->find("template=Championship_results, winner_home_club={$page->id}"); foreach($playerChampionships as $championship) { echo "<li><a href='$championship->url'> $championship->title - {$championship->winner_name}</a></li>"; } ?>
  19. Hi, I have tried both of these options and a few others but none of them work The two you have shown above do not return the page ID, but when I remove ->title, it does return the page ID [1442 being the ID]: County Championship 1995 - 1442 Many thanks J
  20. thanks for this da2, I had tried this but it produced this: County Championship 2023 - 1442->title I have reverted to this: foreach($playerChampionships as $championship) { echo "<li><a href='$championship->url'> $championship->title - {$championship->winner_name}</a></li>"; } ?> This produces County Championship 2023 - 1442 So it's getting the player page ID (1442) but not the title value. As a php newbie I am baffled. Any further thoughts? thanks
  21. One further question if I may: this works fine, but I now want to add winner_name [which is a PageRef field derived from the title field in a separate template, Players] to the string that is returned I have tried this additional text [in bold as below], but it only returns the id number for the winner How can I get it to return the title field from the Players template ie the full winner's name? <?php $playerChampionships = $pages->find("template=Championship_results, winner_home_club={$page->id}"); foreach($playerChampionships as $championship) { echo "<li><a href='$championship->url'> $championship->title - $championship->winner_name</a></li>"; } ?> thanks
  22. thank you for your patience with me! Having now grasped this I am sure I can complete my project as it covers almost all of the functionality needed J
  23. thank you! This now produces the ID numbers for each championship. How would I change that to give the championship page titles as URLs?
  24. thanks, I tried both of these but they both produce an error: Error: Exception: Unrecognized operator: $ (in wire/core/Selectors.php line 416)
×
×
  • Create New...