Jump to content

Listing child pages in new template


jay singh
 Share

Recommended Posts

Hi Guys,

I am new to processwire and am trying to create a job portal for my website but im stuck..

I have a page where the portal superuser can see the jobs posted and it has a button that shows the number of applications (children) of each job. Ideally i want that when that show 1422171175_Screenshot2021-01-17031940.thumb.jpg.56682858aff9124278d0df718b2b385c.jpg

button is clicked, it takes me to a page where i can view all the applications for that job specifically. I have a template created for that page but its just a matter of getting it to only display the relevant applications/children. any guidance would be appreciated.

 This is the code i have to display the jobs in a list by their template

<?php foreach($jobs as  $job){ ?>
 
            <!-- Item #1 -->
            <tr>
                <td class="title"><a href="<?php echo $job->get('url');?>"><?php echo $job->get('title');?></a></td>
            
                <td>January 30, 2020</td>
                <td>January 30, 2020</td>
                <?php $qty = $job->numChildren(true);?>
                <td class="centered"><a href="#"  class="button">Show (<?php echo $qty;?>)</a></td>
                <td class="action">
 
                    <a href=""><i class="fa fa-pencil"></i> Edit</a>
                
                    <a href="#" class="delete"><i class="fa fa-remove"></i> Delete</a>
                </td>
            </tr>   
            <?php }?>

12703518_Screenshot2021-01-17030954.jpg.9fdf34ec42a06211d1f71a915c7ee82e.jpg

Link to comment
Share on other sites

Hi,

not sure i understand the question that well... but i'll try ?
if what you want is to display the content of, say job 1 applications contents, its quite simple, you can use the $page->chidren() method to retreive all the children of the page you're on
if the page you use to display job application is not the job page itself, just start with a method to get the job page

example... you have a single page that will show all the applications for a job depending on a link from the job page itself
on the job page (let's say job 1) make a link with something like job-applications/1017
on the job-application template, allow url segments and now, sure you've guessed, you can retrieve the job page children using that segment (you could use the page name instead of its id, prettier even if a little - very little - more code to retreive the page id using name and template but this is just for the example)

 

$jobpage = pages->get(1017)
$applications = $jobpage->chidren();

job done ?

hope it helps

have a nice day
 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...