Jump to content

Duplicate content in different sections of the site with different URLs


Pete Jones
 Share

Recommended Posts

We have a members area (accessed via a login) which lists a load of horses. Much of the information here is members-only and has been stored as pages in the backend of the website (via a feed).

We now wish to consume this information on the frontend (public) area of the site. 

In my template I can easily grab the horses and loop through them but on the frontend $horse->url returns the members area url so:

members/horses/horsename

Rather than /public/horses/horsename

Is there a sensible way to solve this or am I going to have to resort to creating a custom URL format. grabbing a reference and passing it to the next page?

Many thanks

Pete

Link to comment
Share on other sites

Create a new template and a new page which is public accessible.
Load your horses in a PageArray and echo your output.

To get a specific horse page you can use url segments

if ($input->urlSegment1) {
  $horsename = wire('sanitizer')->pageName($input->urlSegment1);
  $horse = $pages->get("template=horses,name=$horsename,include=all");
  echo $horse->render();
}
else {
  $horses = $pages->find('template=horses,color=black,include=all');
  echo "<ul>";
  foreach ($horses as $horse) {
    echo "<li><a href='/public/horses/$horse->name'>$horse->name</li>";
  }
  echo "</ul>";
}

Assuming you have an overview site where all horses are listet and depending on your href attributes in the links to specific horses you could use

$page->render()

too in the 'else' part above.

Using render() method you maybe have to disable appended/prepended template files by config.php in the template settings.

Edited by kixe
  • Like 1
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

×
×
  • Create New...