SIERRA Posted July 22, 2020 Posted July 22, 2020 Hi, I would like to display all repeater items in a listing page and would like to navigate to the corresponding detail page page based on the selected repeater item I am passing the id of repeater_item like '?id=<?php echo $Admission_Alert->id?>' from the listing page. Then I am fetching the details as below. But this is not working. Please suggest. if (isset($_GET["id"]) and $_GET["id"]!="") $id=$_GET["id"]; $alertspage=$pages->get(id); //var_dump($alertspage) is working echo $alertspage->title //This is not working Thanks
psy Posted July 22, 2020 Posted July 22, 2020 10 hours ago, SIERRA said: $alertspage=$pages->get(id); //var_dump($alertspage) is working Think the issue may be in this line - no $ in front of id. Try: <?php if (!empty($input->get->id) // PW way of accessing $_GET $id = $sanitizer->int($input->get->id); // Clean it up to ensure it's an integer $alertspage = $pages->get($id); // You can also do $pages->get("id=$id") if (!$alertspage instance of NullPage) { // ensure the page exists echo $alertspage->title; } else { echo "There was a problem retrieving the page with ID $id"; } 3
psy Posted July 23, 2020 Posted July 23, 2020 Thanks @SIERRA Oops! Just re-read my code and noticed a mistake. Should be: <?php if (!empty($input->get->id) { // PW way of accessing $_GET $id = $sanitizer->int($input->get->id); // Clean it up to ensure it's an integer $alertspage = $pages->get($id); // You can also do $pages->get("id=$id") if (!$alertspage instance of NullPage) { // ensure the page exists echo $alertspage->title; } else { echo "There was a problem retrieving the page with ID $id"; } } Missed the curly braces surrounding the first and last lines
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now