HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


letting users set how they view galleries

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#78315 (In Topic #16042)
Avatar

Community saint

I know in each gallery you can set if it is flow mode or not.

I want users to be able to set this themselves, as some prefer the scrolling images, some prefer the grid of images.

I figured I could set a custom field for users, and use that to determine if it should display regular or flow mode.

I have to figure out how the custom fields are saved so I can know what to reference/check, but that shouldn't be too hard.   Then go into the galleries.php and edit the check for flow mode to check the user setting instead of the gallery setting.

Sound reasonable and doable?

Paul
Back to the top
 
Posted
Rating:
#78317
Avatar

CPFs are always challenging to program to. There is a proper way to give them names and load them by name, but I suggest you just hard-code your code to know the field ID and do a direct query. Until you're more comfortable with hooks, creating language strings, calling up rare APIs, etc.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#78318
Avatar

Community saint

I kinda figured once I figured out what they are loaded as I would be hard coding the 'check' …

or creating a function that will take the userid and do a quick query and check what is set, but either way I am guessing that will be hard coded as well.

I haven't even looked in the databases to see where all that is store and how.    I am guessing you use a db just for those fields, maybe one for the info on the field, and another one that links user to that field to their data/choice for that field input.

Paul
Back to the top
 
Posted
Rating:
#78320
Avatar

Just hard-code the field ID (a number) and then query out the field_<id>field out of the f_member_custom_fields table against the mf_member_id of a specific member ID.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#78326
Avatar

Community saint

Got it.   So easy it is kinda crazy.

First made a new custom field so a user can select a radio button for slider or grid.

Then in site/pages/modules_custom/galleries.php at the end of do_gallery, change it to the below.

Reversed the check since users that already exist will have nothing in that field yet.  so blank or 'Slider' will do flow mode.

Code (php)

                $modecheck=$GLOBALS['SITE_DB']->query('SELECT field_35 FROM '.get_table_prefix().'f_member_custom_fields WHERE mf_member_id='.strval(get_member()));
        if ($modecheck[0]['field_35']=="Grid")
           return $this->do_gallery_regular_mode($rating_details,$comment_details,$cat,$root,$description,$children,$may_download_gallery,$edit_url,$add_gallery_url,$submit_image_url,$submit_video_url,$title,$rep_image,$fullname);
        else
                   return $this->do_gallery_flow_mode($rating_details,$comment_details,$cat,$root,$description,$children,$may_download_gallery,$edit_url,$add_gallery_url,$submit_image_url,$submit_video_url,$title,$rep_image,$start,$max,$num_galleries,$fullname);
 

Thanks Chris.

Paul
Back to the top
 
Posted
Rating:
#78334
Avatar

Community saint

I've used CPF lookups by name in one on my mods here: View topic: Record users lat/long when they join - ocPortal .

Note that the reason I have the CPF names in variables was to make changing them easier for users instead of burying them in very long query strings.

Hope that helps.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#78343
Avatar

Community saint

Oh, geeez.

If Arbo and temp (and Falko) team up, we might be treated to some real surprises.

Bob
Back to the top
 
Posted
Rating:
#78344
Avatar

Community saint

eh, I go in spurts of understanding.

Most of the time I don't know what's going on… but that may be due to having kids.  They seem to drain the smart right out of you.  

 :P

Paul
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: