Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hello

Is there a parameter for editables to allow only unique values within cloned pages of a template? Meaning that Couch should give an error if someone tries to save a value and the value exists already in another cloned page.

A solution might be the following:

Code: Select all
<cms:set unique="<cms:pages masterpage='userprofiles' custom_field='username==<cms:show frm_username />' ids_only='1' />" />
<cms:if unique==''>
   <p>Username does not exists!</p>
    <cms:db_persist
      ...
      />
<cms:else/>
   <p>Username already exists!</p>
</cms:if>


But will the performance be ok with this solution if there are several thousand 'users'?

Regards,
Olliwalli
Please clarify - is this solution required for the backend (when Admin edits a cloned page) or solely frontend (submission of some form)?
It would actually be great if it works both ways, because it is possible that the admin has to change the username for a client. Primary it is necessary for the frontend so that the client can change his username himself.

My possible solution would work only in the frontent.

Some plugin introducing this check could work for both.
Since we are talking about users, you are not using Extended Users addon? It could be a breeze without any tweakings. Username would be a page_name, which is a system field that doesn't allow duplication. Ask user or admin to change k_page_name (instead of k_page_title ) and Couch would do the unique check, validation and error reporting, which is quite nice.
My reason for not using Extended Users addon is the fact that we have two separate types of users that have completely different editables and functionalties.

The access for the clients will be limited to only one cloned page, where internal users should manage all clients and data.

An addon which introduces a parameter "unique='1'" for a specific editable would be great. But I have no idea if this can be done with adding a custom function in addons/kfunctions.php.
What you want perhaps could be done via custom php coding in kfunctions.php and @KK knows better if it's possible. :D

However, I have in my past done Extended Users addon and at the saem time there were various groups of users, with different access-control. Most profiles have same editables, but if some editables are not necessary for admins, they can be left empty maybe. I haven't seen real samples of why you don't want to use EU addon, and so far I can suggest to make things simpler, not over-complicated. :)
Assuming that the user name is k_page_name there is a function in couch which allows you to check if the page already exists

Code: Select all
<cms:set new_username="Olliwalli" />

<cms:if "<cms:page_exists name=new_username masterpage='userprofiles.php' />">
   <p>Username does not exists!</p>
    <cms:db_persist
      ...
      />
<cms:else/>
   <p>Username already exists!</p>
</cms:if>
7 posts Page 1 of 1

Who is online

In total there are 4 users online :: 1 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: Exabot [Bot] and 3 guests