Interesting Look-up Issue

6 posts by 2 authors in: Forums > CMS Builder
Last Post: April 27, 2012   (RSS)

Re: [Perchpole] Interesting Look-up Issue

By Jason - April 26, 2012

Hi Perch,

So if I understand this correctly, the record is created by a user, who belongs to a group, and a group has an icon that you want to be able to display. Is that right?

If so, you should be able to access the group record using the createdBy. fields in the record you are outputting.

For example, lets say that your group records are stored in a section called "groups" and in your user accounts, there is a field called "group" which stores the record number of the group that a member belongs to (this is assuming that a user can only belong to 1 group at a time). Once you're outputting that record, you could get the group record like this:

<?php
list($groupRecord, ) = getRecords(array(
'tableName' => 'groups',
'allowSearch' => false,
'limit' => 1,
'where' => "num = '".intval($record['createdBy.group'])."'",
));

$group = @$groupRecord[0];

?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Interesting Look-up Issue

By Perchpole - April 27, 2012

Hi, Jason -

Thanks for this. Unfortunately the solution won't work for various reasons, not least because some users will have access to multiple groups.

Perhaps I should try to simplify the issue...

Let's say I have created 10 records - all assigned to the same category.

On "Record 1" I upload a picture.

How do I then pull that picture on to the other 9 records?

:0/

Perch

Re: [Perchpole] Interesting Look-up Issue

By Jason - April 27, 2012

Hi Perch,

In the scenario you're describing would it work to upload a picture to the category? Then, as long as we know what category a record belongs to, you can then access that category record, and get the image.

Does this work?
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Interesting Look-up Issue

By Perchpole - April 27, 2012

In the scenario you're describing would it work to upload a picture to the category? Then, as long as we know what category a record belongs to, you can then access that category record, and get the image.


Hi, Jason -

That's how I would have prefered to do. It's how I've done it before. However, in this instance, it would be impractical.

CMSB's "User Account" settings for categories are different to the settings for normal records. There is no "Author" status - which means anyone with access to the categories would be able to edit all of the records found there.

That's why I've been forced to use the approach described at the top of this thread!

:0)

Perchpole

Re: [Perchpole] Interesting Look-up Issue

By Jason - April 27, 2012

Hi,

Author access to a category is tricky, given the hierarchical structure of a category section.

How are category records being created currently? One approach would be to only give certain users access to the category section at all and have them be responsible to uploading the images.

If you wanted the uploads to be on a "per record" basis, you could do a loop through all the records in a given category, and then stop when you find the first one with an image, using that image in multiple places.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/