Please figure revisiting previous posted issue (not sure of the protocol here) but given it has been closed and a follow up post was made there with no response I though it might be reasonable to open a new ticket on this.

The advise given in enabling a teaser block view is to override theme_taxonews_block_view($delta, $items = NULL) . Could you give an indication what this entails for the non-php literate amongst us. Taxonews is a very timely module and provides almost exactly the functionality I require excepting the teaser view. If it is more appropriate to request paid modifications I am happy to go in that direction.

Cheers

Comments

chlobe’s picture

First line should read 'Please forgive'

chlobe’s picture

Component: Code » Miscellaneous
fgm’s picture

Creating a new issue as you did is indeed the proper way to do things, AIUI.

In order to override theme_taxonews_block_view, you just have to define a theme function in the theme used for your site. Supposing the custom theme your site is using is a plain PHP theme (like Chameleon), called "chlobe". In that case, you'll just have to add a function called: chlobe_taxonews_block_view($delta, $items = NULL) in the chlobe.theme file.

In that function, you can then ignore $items, since it contains the links to the articles and you want the teasers. So you use $tid to query for the teasers of nodes matching that tid, and display them, with a query like (assuming you ignore the various ordering choices available and go for the default ordering):

SELECT n.nid, n.title, nr.teaser 
FROM {node_revisions} nr
  INNER JOIN {node} n ON nr.vid = n.vid
  INNER JOIN {term_node} tn ON n.nid = tn.nid
WHERE tn.tid = %d AND n.status = 1
ORDER BY n.created DESC, n.changed DESC

Looping on the db_query()/db_fetch_array() results, you build an array of what you want to see, typically $row->teaser, and pass it to theme_item_list to format it as a standard list under the site theme.

The same mechanism can be transposed with other theme engines like phptemplate. Or the feature can be added to the module itself.

chlobe’s picture

Thanks so much, I will examine the fix as soon as I get a chance, thanks again. Please see PM.

Cheers

andyt’s picture

If I understand comment #3 the user is being asked to re-query the data to get the teaser.

I am interested also in having access to other node data for the similar purpose of presenting the data in other formats (other than as currently formatted in blockView()). After studying the code it would seem the $items array would contain the title, teaser, and possibly other node data without being formatted as a link in blockView(). Then the user can 'theme' the data as needed in block_view(). The default block_view() would format the link just like blockView() does now.

It seems the krsort function is not necessary since the data is already sorted by the SQL. In fact it may be un-sorting the data since the sort is by nid and not by 'views'. I can understand why by nid since views may have duplicate values (though unlikely).

I'm using Taxones 6.x-1.x-dev.

andyt’s picture

After further thought the user can retrieve as suggested in #3 the {node_revision} data in block_view(). However, blockView should not pre-format the data from {node} (leave the title in array $items as is) so the database access to {node} is not needed a second time.

fgm’s picture

Status: Active » Needs review

Please try the new version. Several changes have been applied in 6.1.0 RC, notably reducing the number of requests. The krsort() is needed because it acts after the node selection whereas the SQL is part of the node selection process.

fgm’s picture

Status: Needs review » Fixed

No comment. Assuming RC satisfies user's need.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.