override specific block data to a block
Permalink
I'm trying to build a block called "My Favorites". This is so logged in users can add links to a block that will list their favorite links. I have created a table with bID, cName, cPath, and uID. In the controller, I have a select statement to pull the data based off of their user ID...
The problem I'm having is that it seems to only show the data that was created within that specific block when a new block is added on the site. For instance, if I had one link created at the time of adding a block to a page, it only shows one link. If I add another block to that very same page and add three more links, it will show those three links plus the one previously created, but the earlier block created only shows the one link. How do I override the search on the bID? I think this is where my problem is.
class MyFavoritesBlockController extends BlockController { function getNavigationArray() { $u = new User(); $uID = $u->getUserID(); $q = "select * from btMyFavorites where uID = $uID "; $db = Loader::db(); $r = $db->query($q); return $r->GetArray(); } }
The problem I'm having is that it seems to only show the data that was created within that specific block when a new block is added on the site. For instance, if I had one link created at the time of adding a block to a page, it only shows one link. If I add another block to that very same page and add three more links, it will show those three links plus the one previously created, but the earlier block created only shows the one link. How do I override the search on the bID? I think this is where my problem is.
You'll need 2 tables to do this, one for your block data, where one row represents each instance of the block on your site, and one for storing the link data by user.
It sounds like you're storing the favorites in the blocks instance table.