Jump to content

Multiple pages (page array)


Mijo
 Share

Recommended Posts

Hello all, I'm trying to get all selected tags on my news list,  so far when I go to specific news I see tags that I selected for that news, but when I'm on news list I see all tags that exists, not once that I selected.

Tag field is page reference, I have selected Multiple pages (page array), input field type Amselect.

My code so far looks like this:

    <?php
				$tags = $pages->get("/tag/")->find();
				foreach($tags as $tag){ 
				echo "<li><a href='{$tag->url}'>{$tag->title}</a></li>"; 
		}
		?>

Can you help please with some advice how to get only selected tags on my news list?

Link to comment
Share on other sites

I think what you are looking for is:

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

I assume when you say "go to specific news" that means a page with a single news item.

 

Link to comment
Share on other sites

3 hours ago, adrian said:

I think what you are looking for is:


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

I assume when you say "go to specific news" that means a page with a single news item.

 

Thanks for the reply but unfortunately it does not work,  tags are not showing. With my code above I achieve that tags (selected tags for news item) showing on single news, for example test 1, test 2 but when I am on to news list I see all tags that I have created. newsList.png.899ca0b177dfad2d17da4ac3520175ac.pngnews_single.thumb.png.4a10cc84da86675a61a83bca899710ee.png

Link to comment
Share on other sites

@Mijo Try this:

//Grabbing the news list
$posts = $page->children("limit=10");

//Rendering each news post
foreach($posts as $post) {
    echo "Lorem Ipsum...";

//Rendering selected tags inside each post
foreach($post->tags as $tag) {
    echo "<li><a href='{$tag->url}'>{$tag->title}</a></li>"; 
}

}

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

19 hours ago, PWaddict said:

@Mijo Try this:


//Grabbing the news list
$posts = $page->children("limit=10");

//Rendering each news post
foreach($posts as $post) {
    echo "Lorem Ipsum...";

//Rendering selected tags inside each post
foreach($post->tags as $tag) {
    echo "<li><a href='{$tag->url}'>{$tag->title}</a></li>"; 
}

}

 

Thank you very much! :-) 

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...