Not unique table/alias: 'g2_Item'

almandot

Joined: 2007-05-03
Posts: 13
Posted: Sat, 2009-02-14 23:55

I'm trying to extend the DynamicAlbum module so that I can make dynamic albums on the fly based on a range of dates. I'm implementing the range by using a starting timestamp and an ending timestamp.

The call that's getting made to buildItemQuery is

list ($ret, $query, $data) = GalleryCoreApi::buildItemQuery(
$table, $id, $query, $orderBy, $orderDirection,
$class, 'core.view', false, $userId);

table is GalleryItem since that's where originationTimestamp is stored, the query adds an originationTimestamp BETWEEN start and end clause to what dynamicalbum already generates, and this is the error I'm getting in the log:

Quote:
Query: SELECT g2_Item.g_itemId, g2_Item.g_originationTimestamp FROM g2_Item INNER JOIN g2_Item ON g2_Item.g_itemId = g2_Item.g_id INNER JOIN g2_DataItem ON g2_Item.g_itemId = g2_DataItem.g_id INNER JOIN g2_AccessSubscriberMap ON g2_Item.g_itemId = g2_AccessSubscriberMap.g_itemId WHERE g2_Item.g_itemId IS NOT NULL AND g2_Item.g_originationTimestamp BETWEEN 0 AND 1234654301 AND g2_AccessSubscriberMap.g_accessListId IN (15,6912,6913,6914) ORDER BY g2_Item.g_originationTimestamp, g2_Item.g_itemId failed. Not unique table/alias: 'g2_Item'
1066: Not unique table/alias: 'g2_Item'

The other portions of dynamicalbum still work fine(an album based on recently added, most viewed, and random items). If you'd like to see a working query made by one of those other options, here's the one for Recent Updates(the last 24 items added to the gallery). Here it's using Entity for the table though since that's where creationTimestamp is...

Quote:
SELECT g2_Entity.g_id, g2_Entity.g_creationTimestamp FROM g2_Entity INNER JOIN g2_DataItem ON g2_Entity.g_id = g2_DataItem.g_id INNER JOIN g2_AccessSubscriberMap ON g2_Entity.g_id = g2_AccessSubscriberMap.g_itemId WHERE g2_Entity.g_id IS NOT NULL AND g2_AccessSubscriberMap.g_accessListId IN (15,6912,6913,6914) ORDER BY g2_Entity.g_creationTimestamp DESC, g2_Entity.g_id LIMIT 24

Anyways, I'm confused on how to approach this. Any help is appreciated.

p.s. here's the entire error log for that portion of what happened if it helps

AttachmentSize
errorlog.txt5.21 KB
 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2009-02-15 00:46

Write a new module for what you want, rather than extending an existing core module. You can use the "title" module for inspiration, it does pretty much what you want, you just need to change the query.

(If you do, I've got an update for 2.3 to include.)

 
almandot

Joined: 2007-05-03
Posts: 13
Posted: Sun, 2009-02-15 08:44

Is it a core module? I know keywordalbum is but I had to download dynamicalbum separately.

All of the other album-by-date attempts I've seen, such as adaptations of the title module into a date module, involve using the searchbox to some degree and the problem with that is it limits it to only 1 day or 1 month etc at a time you can't say I want everything from between January 28th and February 4th of 2009. Furthermore I want something that I can then store as a link item album so it's viewable to people and they can click it and then see that collection of photos, and the search interface doesn't allow for that. The only thing that did was something like a keywordalbum or the sets in the dynamicalbum. dynamicalbum had the best headstart on what I wanted to do so I did my changes to that one..

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2009-02-15 11:09
Quote:
Is it a core module?

No, it's a -contrib module.

 
almandot

Joined: 2007-05-03
Posts: 13
Posted: Sun, 2009-02-15 22:36

I figured it out. I'm dumb ;). For some reason I thought Item used itemId instead of just id for its table name but that's the ItemAttributes table. Oh well. it works =) Now i'm going to add a tab on the add items page so you can pick dates from a calendar and save them as album links(I read that I should use the yui calendar since gallery2 already makes use of yui elsewhere) and then I'll upload it if people think I should.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2009-02-16 05:16
Quote:
and then I'll upload it if people think I should.

Yes. All contributions help.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
almandot

Joined: 2007-05-03
Posts: 13
Posted: Tue, 2009-02-17 07:00

I've looked through core a bit and am wondering if I'm correct in that there's currently no way to add an extra plugin tab in the Add Album page similar to how you can with Add Items.

I haven't looked at Gallery3 yet, but are there plans for including Smart Albums in it? Cuz that's basically what I'm attempting to do... A pretty standard feature in photo albums, music playlists, etc.. these days. Rather than what dynamicalbum did, where it is a dynamic album in the sense that the content changes but the album itself is predefined, it really should just be a matter of adding an album and opting to make it a dynamic one and then choosing from any of the columnnames already available to order your items by and then getting the option of a parameter such as is, is not, contains, is between, etc.. It's something that I'd think is much better suited for when doing Add Album rather than just adding the plugin to Add Items.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2009-02-17 09:35
Quote:
it really should just be a matter of adding an album and opting to make it a dynamic one and then choosing from any of the columnnames already available to order your items by and then getting the option of a parameter such as is, is not, contains, is between, etc..

That sounds exactly like a regular dynamic album to me - what's the difference?

You can implement a new kind of GalleryItem that is your SuperDynamicAlbum if you want. As long as it returns true to ->CanContainChildren() then Gallery should treat it as an album etc.

 
almandot

Joined: 2007-05-03
Posts: 13
Posted: Tue, 2009-02-17 12:02

It is a regular dynamic album, but there's no regular dynamic album implemented in gallery2 yet as far as I can see... the API supports them but there's no implementation yet where a user can add a dynamic album, set their conditions for it, and have it show up on a page in their gallery. As it is now with the dynamicgallery module, they exist only as urls to an album.. I can't store one in my gallery as a subalbum(unless I create a linkitem redirect). Plus the dynamicalbum module only provides those 3 albums(most popular, most viewed, and random) with their conditions preset and unchangeable unless you go in and hard code something else like I did. They're dynamic albums but with static conditions.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2009-02-17 12:15

OK... I see what you're after now. The Gallery concept of a dynamic album as implemented isn't actually an album at all, as it's not a GalleryItem in the database. It's a "dynamic view".

There's no reason why you couldn't implement what you're after though. But I don't think it would be accurate to call it any kind of "album", as you can't add items to it - it wouldn't ever be the parent item of another GalleryItem.

To do what you want would be pretty simple, in fact. Implement a more flexible dynamic album (of the existing type) where you can specify the conditions more carefully in the header or url parameters, then have a new GalleryItem that stores a set of those condition and has a page to edit them which when rendered produces a link with the right parameters. Job done.