50 Posts
rtlehr
6 years ago
Topic

Hey all,

     I'm creating a gallery that gives the owner the ability to protect (hide) some of there images if they would like, then unhide them for different users when they so desire. Here are the details

I've created a gallery item article for each image.  Included is a radio field for the user to choose to protect the image (Yes/No options) If the user picks yes, the image will be protected and only invited users will be able to see it.

I've created a gallery owner to viewer relationship article for the gallery owners to store which user can view their protected images.

So, the process would be, a viewer would ask the owner permission to view their images, the owner would click "yes" and the owners ID and viewer ID would be stored in the relationship table.

SO, I've created a Select - Dynamic field to check and see if a viewer has permission to view the images I created an SQL statement to return a 0 if the user does NOT have permission and a 1 if the user does. 

SELECT CASE

WHEN EXISTS (

SELECT *

FROM #__gallery_item

WHERE id = 56

and protect_image = 'Yes'

)

THEN

( SELECT count(*)

FROM #__gallery_item_user_relationship

WHERE gallery_viewer = 47 and gallery_owner = 45)

ELSE 1

END

I then created a LIST to show all the images in the gallery.  What is supposed to happen is for each image the dynamic box checks to see if the current user can see the images. The way the SQL is set up is

SELECT * FROM #__gallery_item WHERE id = 56 and protect_image = 'Yes' <-checks to see if the image is protected (56 is the current art_id for the image)


if it is protected


( SELECT count(*) FROM #__gallery_item_user_relationship WHERE gallery_viewer = 47 and gallery_owner = 45) <- check if the current user has permission to view the photos (47 is the current users ID and 45 is the owner of the gallery)

NOW THE QUESTION!! I know I can plug in $user->id to get the current users id (47) and I can pass the owners ID (45) in the URL and grab it with

$uri->getValue('owner_id') BUT, I can not figure out how to capture the ID of the image I am checking, in the above example it would be the 56.  I tried $ccl->getValue("art_id") but that has not worked.

Anyone have a clue? Thanks a lot.

I know that a long explanation and not sure I made a lot of since, so if you have any questions, please let me know.

Thank you,

Ross

Get a Book for SEBLOD
4229 Posts
Kadministrator
6 years ago
0
Level 1

Unfortunately you can't use values from other fields in select dynamic. You could use code plugin to to your checks in beforeRender or use template override for list (only works in item mode).

50 Posts
rtlehr
6 years ago
0
Level 1

Thanks for the help.  I have the code plugin pack, but have not dived into it yet, I'll have to take a look.  I'll try the template override also.

Thanks for your help,

Ross

1283 Posts
Bucklash
6 years ago
0
Level 1

The other day I wanted to render an accordion.

It was the buttton ie 'images'

and in the accordion was a list ie 'list if images'

In the button I wanted to display the total images in the list.

After a lot of trial and error I made a custom template that pulled in the total for the button

Could have used js but didn't

So maybe creating new template based on seb_list etc could be the way

50 Posts
rtlehr
6 years ago
0
Level 1

I ended up using a position override and Joomla's SQL to grab the info I needed.

Get a Book for SEBLOD