ℹ️
Welcome to the archive of the old FlatPress support forum. Browse more than a decade of FlatPress wisdom! Login is disabled.

The current FlatPress support forum is available here: forum.flatpress.org
Related Entries
  • Hi, I've added to my tag plugin the "Related Entries" feature, but I won't release it at the moment because I've a doubt: now to get related entries this is the logic block: 1) get tags of the entry (so parse the entry content) 2) for every tag (linear parsing of an array), I get the list of entries that have that tag and I add them to an array ($related) with: id, subject (FPDB query but just one per entry), creation time (date_from_id so mktime) and number of common tags between the two entries. However if the entry already exists in $related, I just increment the number of common tags. 3) I sort $related with a callback that check the number of common entries and the pubblication time: there are first entries that have more common tags and if this number is equal newer entries "wins". 4) I save in a cache file 5) I slice the array to get just a number of entries (5-10). I'm not sure of the caching file: I think that is better caching this procedure, but the cache file become very very big and I risk that for an entry I load in RAM the whole related posts of a blog. I've considered many possibilities: 1) Slice the array before caching it (you can't change the number of entries, but you can also delete cache!) 2) Make different cache files, for example tag-related-YYMM, like PrettyURLs 3) Don't make a cache. @NoWhereMan or other users: what do you think?
  • Ok, I've made some tests, with the solution number 2. I've made the test on my blog, that has 300 entries and at least 4 tags per entry. The sums of files size is 2213238, so 2MB... Loading them for just a post it's not a good idea. The size of a single file isn't the same: the lightest is about 20kB, the largest is about 200kB, so I think I'll use this way.
  • Any News an that Plugin? Woulf be very neat :)
  • Hi, I've added it to the tag plugin ;-)
  • Hey I'm sorry to bring this up but do you mean that the tags are kind of related entries? Just because I looked into the plugin.tag php and found

    # The number of related entries
    define('PLUGIN_TAG_REL', 10);

    Also I get the "error" managing the widgets (raw):

    The widget called tag is not registered, and will be skipped. Is the plugin enabled in the plugin panel?
    But its there:     4 => 'tag', and its activated in the plugin panel.

    EDIT:
    I found the related widget in the admin panel^^ didn't see it :D But, how do I get it under my entrys? I tested and draged the Related widget in the side menu but I only see the word "error" in the widget.
  • The word error is shown when you aren't in an entry.
    You should create a new widgetset for the related entries, called related_entries or entry_foot or all names you want and then insert there or use the {related_entries} tag in the tpl file.
  • Thanks, I added {related_entries} in the entry-default tpl and replaced "Error" in the language file with a blank space. so I don't see the word "Error" at the bottom of every entry when I'm on the blog index.
  • @pierovdfn: you have add it to the tag plugin? Which is? SimpleTags?
  • Yes I've added to my tag plugin.
Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion