anchor-cms icon indicating copy to clipboard operation
anchor-cms copied to clipboard

Can't use article functions in search results

Open adamgreenough opened this issue 8 years ago • 2 comments

Summary

Functions such as article_author(), article_description() etc do not work on search.php (in theme folder).

Expected Behaviour

Expect them to work as they do on posts.php.

Actual Behaviour

They do nothing.

Context details (if applicable)

  • Anchor version: v0.12.1
  • Server setup: MediaTemple Grid
  • URL: adamgreenough.com

I tried other themes from AnchorThemes that demonstrate this works in their demos but it does not work on a clean version of 0.12.1.

As a workaround, I wrote these functions based on the ones in the default theme..

`function search_item_description() { return Registry::prop('search_item', 'description'); }

function search_item_author() { return Registry::prop('search_item', 'author_name'); }

function search_item_time() { if($created = Registry::prop('search_item', 'created')) { return Date::format($created, 'U'); } }

function search_item_category() { if($category = Registry::prop('search_item', 'category')) { $categories = Registry::get('all_categories'); return $categories[$category]->title; } }`

adamgreenough avatar Jul 03 '16 23:07 adamgreenough

Hmm, this is a bummer. Was hoping that the search.php layout file had undergone fixes since I last dealt with it. It should be considered just like any other view

daviddarnes avatar Jul 04 '16 08:07 daviddarnes

The only issue I see with this is we can't just straight up add in item_description because with the functionality of posts and pages being searched, pages don't have a description, which would leave to something unwanted.

But I thought I had fixed this a while back - I'll keep digging and see what I can find...

Edit: Found the commit I was thinking of - turns out that I was wrong and that I only changed the pages and menu items to fit the above paragraph... Not sure how effective it'll be if we do the same sort of thing with the posts, and then return objects/arrays/content-types and content-IDs from the search functions?

TheBrenny avatar Jul 07 '16 15:07 TheBrenny