Can't link authors profile

Hi wondering if you can help

I’m struggling to link a user’s name to their profile page. I have this route set

c::set('routes', array(
      'pattern' => 'profile/(:any)',
      'action'  => function($user) {
        $site = kirby()->site(); 	
        tpl::load(kirby()->roots()->templates() . DS . 'authors.php', array('user' => $user, 'site' => $site), false);

Which works perfectly in the browser, however I cannot seem to get the following to link up

<?php if($author = $pages->find('profile/' . $page->author())): ?>  
      <h1><a href="<?php echo $author->url() ?>"><?php echo $thread->author() ?></h1>
    <?php endif ?>

It doesn’t show the actual $thread->author() output now with the above.

I’m afraid I don’t quite understand what you are doing here. What is in your authors template? Is that code snippet part of the authors.php template?

Why do you need the route if you have author pages?

And what is $thread?

Sorry, so, i wanted to list all directories under forum, so using this code, which outputs what’s needed,

    $threads = page('forum')->children()->sortBy('date', 'desc');
    if(isset($limit)) $threads = $threads->limit($limit);
    <ol class="cards">
    <?php foreach($threads as $thread): ?>
    <div class="listing">
    <a href="<?= $thread->url() ?>">
    <?= $thread->title()->html() ?></a></div>
    <div class="stats">  
    <?php if($author = $pages->find('profile/' . $thread->author())): ?>  
    <h1><a href="<?php echo $author->url() ?>"><?php echo $thread->author() ?></h1>
    <?php endif ?>
    <br /><?= $thread->date('d.m.Y H:i') ?></div>
    <?php endforeach ?>
  <?php endforeach ?>

I just want to be able to link the author of $thread to their corresponding profile page.

But do these author pages really exist?


$author = $pages->find('profile/' . $thread->author())

will only return an author if you have a page folder. Since you are using a route, I have a feeling these pages do not really exist…?

If I’m correct, you’d have to generate the URL like this to link to your route.

<a href="<?= url().'/profile/'.$thread->author() ?>">

Please, when posting code blocks, wrap them in three backticks on a separate line before and after the code block. Thanks.

Many thanks for this… and oops sorry will do in future!