osclass / Osclass

With Osclass, get your own classifieds site for free. Build your own Osclass installation and start advertising real estate, jobs or whatever you want- in minutes!
http://osclass.org/
649 stars 342 forks source link

View export variables possible issue with 'latest items' or 'search' #142

Closed garciademarina closed 12 years ago

garciademarina commented 12 years ago

osc_has_latest_items() - count_latest_items() goes to find 'items' or 'item' from View.

BUT:

If you on some plugin needs to use 'item helpers' you need to do: View::newInstance()-> _exportVariableToView('item', $your_item );

But if you do that just before osc_has_latest_items(), gets incorrect Variable from view.

We need to refine variables names for common querys like latestItems or searchItems.

conejoninja commented 12 years ago

Then you will need another set of helpers since oscitem* will not work ... I don't think there's a problem here. Yes, more than one "search" on the same page will collide and cause problems but it could be easily avoid saving the previous query before.

Default OSClass behaviour does not make any problem. For third party code and plugins, the suggested code is :

$saved_items = View::newInsatence()->_get('items'); /* SOME CODE HERE USING oscitem* helpers */ View::newInstance()->_exportVariableToView('items', $saved_items);

juanramon commented 12 years ago

I don't think so. We could set two variables:

View::newInstance()-> _exportVariableToView('latest_items', $latest_items );
View::newInstance()-> _exportVariableToView('items', View::newInsatence()->_get('latest_items') );

Then, at the end of the loop, we reset items and the latest items will be available in _latestitems. I'm not sure if I explained well...

conejoninja commented 12 years ago

This issue has been solved. A change in the theme has to be made, on functions.php

I added three more helpers, osc_has_custom_items / osc_count_custom_items / osc_reset_custom_items Now, if you want to create a plugin or a module you need to export your items to 'customItems' variable

View::newInstance()->_exportVariableToView('customItems', $your_items);

Using this, you will not need to worry about conflict