Jump to content

Recommended Posts

Posted

Hi guys. I need to create a field (link field) that allows me to select the internal pages to use as links. Do you have any suggestions? Thank you.

Posted

Hi,

Unless I'm misunderstanding something here, what you want is actually a Page field. In your template files you can output the URL of the selected page:

<?php if ($page->page_field_name): ?>
    <a href="<?php echo $page->page_field_name->url; ?>"><?php echo $page->page_field_name->title ?></a>
<?php endif; ?>

Does that sound about right?

  • Like 1
Posted

'pages' and 'links' sound plural to me. If that's the case, you still use Page field ('Page Reference' in UI) but iterate over it. May look like this:

foreach($page->page_field_name as $link)
	echo "<a href='{$link->url}'>{$link->title}</a>";

 

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
×
×
  • Create New...