Module want: Related pages
#1
Posted 09 December 2011 - 07:33 PM
I would like to have a module which shows me related pages to the current (or an PageArray).
Greets,
Nico
#3
Posted 10 December 2011 - 04:18 AM
#4
Posted 10 December 2011 - 04:50 AM
Simply create a new field with type "Page".
Under the Details tab make sure "Multiple Pages" is selected.Under the Input tab, change "Parent of selectable page(s)" to be your parent blog page (ie. the page that all your articles come under). Finally, change "Input field type" to be asmSelect to allow you to mre easily select multiple blog entries.
That's the hard part done. Then in a template you can iterate through that field and display links to related pages
EDIT: I guess that technically you would want the link to work both ways though so it you link one page to another then if you're viewing the other page it would link back, but it wouldn't be too hard to do - simply do an additional search on all pages with the "relatedpages" field and return results with a link to the current blog entry - that way you don't have to worry about adding links between multiple pages.
#5
Posted 10 December 2011 - 05:48 AM
But i'm guessing you want something a little more 'automated'. A module/class that would allow you define some parameters like which pages and fields you want to search for possible relations, give fields a weight, excludes stopwords, and then searches and calculates a ranking/resultset based on the things you define.
You would call this module/class in your template, possibly using MarkupCache to avoid a performance hit.
Could you elaborate on what functionality you would like to see in your "Related pages" module?
#6
Posted 10 December 2011 - 06:30 AM
$page->relatedPages as $relatedPage {
echo $relatedPage->title; // $relatedPage should be a PageArray
}
It should work completely automatically. And I want to have an option page where I can say what is the most important point in which they should be related with. And maybe the second important and the third or so.
I guess it would work like a specified search which caches like 5 related page in each page. And if I create a new page it looks for related pages and saves them in the "relatedPages" field (so it probably should be a Fieldtype). So the module wouldn't increase the front-end's loading time.
#7
Posted 10 December 2011 - 06:54 AM
If you could give us a better idea of how you would see it being automated ie. what the module is looking for in order to determine how a page is related, then I'm sure we can come up with other suggestions.
#8
Posted 10 December 2011 - 07:03 AM
#9
Posted 10 December 2011 - 07:05 AM
#10
Posted 10 December 2011 - 10:59 AM
Then you can grab all articles from that category reasonably easily to display on the category page (we'll get back to the automatically related articles in a bit) using something like this where $page->name is the category page you're viewing:
$articles = $pages->find("category=$page->name, limit=50"); where 50 is the limit for the number of articles to return.In terms of tagging, you simply get all tags for the current page (we're assuming "tags" is a text field with just comma-separated tag names) and use similar code to the above to return all articles with the same tags:
$related_articles = array();
$tags = explode(',', $page->tags);
foreach ($tags as $tag) {
$tag = trim($tag);
$articles = $pages->find("tags*=$tag");
foreach ($articles as $article) {
if (!isset($related_articles[$article->id])) {
$related_articles[$article->id] = $article; // Not sure if this saves any overhead - just makes sure we're not overwriting duplicate array entries if 2 articles have the same tags
}
}
}
Then you can iterate through your $related_articles and print the list.
I'm not sure if the search is case-sensitive, but I would suggest inputting all your tags in lowercase just to be on the safe side.
Another interesting thing you can do is count the number of times a tag appears and create a tag cloud for all your articles (this would require getting all tags for all articles, but it's just a variation on the above).
#11
Posted 10 December 2011 - 01:07 PM
#12
Posted 10 December 2011 - 03:27 PM
$articles = $pages->find("category=$page->name, limit=50");
You can just use:
$articles = $pages->find("category=$page, limit=50"); The $page is the current category page, which serves also as the catergory page to select in the articles. So category is a page reference field on the article pages.
Also you could use template with urlSegments enables to setup a page "categories" that lists pages from a category, you can use like: /categories/categoryname/
Then use something like this:
$cat = $sanitizer->pageName($input->urlSegment(1));
$articles = $pages->find("category=$cat, limit=10");
Edit: Sorry corrected some in the code, its $input->urlsSegment() not $page->urlSegment(). And $sanitizer-> not $page->sanitizer
@somartist | modules created | support me, flattr my work flattr.com
#13
Posted 10 December 2011 - 03:37 PM
You can just use:
$articles = $pages->find("category=$page, limit=50");
Very good point
#14
Posted 21 March 2012 - 06:09 PM
I've not got to writing any code yet, just setting up fields/templates.
I have a hidden parent page called 'Tagging' and under it a page per tag.
But when I am in the editor and adding a new tag (page) or two, the resultant pages are not set to 'Hidden'.
I've tried to make them hidden by changing my template Access settings but that was only an educated guess — is there a way to make pages create pre-set to hidden, or, as the pages are under a hidden parent am I safe to not care that they are not hidden?
Any comments gratefully received
Edit: Larger question may be -- am I wrong to have the parent of the tags as a hidden page in my hidden '_Tools' section rather than calling it, say, 'tags' and having it visible immediately under Home?
#15
Posted 21 March 2012 - 07:10 PM
As for the larger question: I wouldn't say you're wrong, but you could have all the tags listed on your tagging page, and on each tag page, all the articles tagged with it. It's not much work, and maybe nicer than having them hidden.
#16
Posted 22 March 2012 - 06:01 AM
If you assign to those pages a template without file they will always be hidden and you don't have to worry about it
Excellent.
And if you don't want them to be viewable, I'm assuming you didn't setup a template file.
Correct.
As for the larger question: I wouldn't say you're wrong, but you could have all the tags listed on your tagging page, and on each tag page, all the articles tagged with it. It's not much work, and maybe nicer than having them hidden.
I don't understand that, but I'm experimenting with tagging today so I will see if I can understand it when I've done a little more learning. Thanks diogo for the help.
#18
Posted 22 March 2012 - 06:54 AM
Ah I understand, thanks diogo and NO need to apologise!sorry for the messy sentence
I just meant having them visible as in any blog
#19
Posted 22 March 2012 - 07:52 AM
@somartist | modules created | support me, flattr my work flattr.com
#20
Posted 22 March 2012 - 07:58 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













