Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Hi Guys!

I have extended user template that contain :
Code: Select all
<?php require_once( 'asep/cms.php' ); ?>

<cms:template clonable='1' title='Users' routable='1' hidden='1'>
   
   
      <cms:editable
         name='upline1'
         label='Upline 1'
         type='relation'
         has='one'
         reverse_has='many'
         masterpage='user.php'
         order='1'
      />
      
      <cms:editable
         name='upline2'
         label='Upline 2'
         type='relation'
         has='one'
         reverse_has='many'
         masterpage='user.php'
         order='2'
      />
      
      <cms:editable
         name='upline3'
         label='Upline 3'
         type='relation'
         has='one'
         reverse_has='many'
         masterpage='user.php'
         order='3'
      />
   
   
   <!-- define routes -->
    <cms:route name='list_view' path='' />
       
    <cms:route name='page_view' path='{:page_name}' filters='page_exists=name'>
        <cms:route_validators
             page_name='title_ready'
        />
    </cms:route>
   

   
</cms:template>

   <!-- find the matched route (view). Respond with 404 if no route matches. -->
    <cms:match_route debug='0' is_404='1' />
   
   <!-- implement the selected view -->
   <cms:if k_matched_route='list_view'>
        <cms:abort is_404='1' />
    <cms:else_if k_matched_route='page_view' />
        <cms:embed 'registar.html' />         
    </cms:if>

<?php COUCH::invoke( K_IGNORE_CONTEXT ); ?>



When a user register, he need to choose 3 upline. But what i want is :

In every user page view "http://www.site.com/user/user-name", i put a registration databound. And to register, the new user will ask the registered user page view link to register and the "upline1" will become the current accessed user page view.

I hae try this with db persist form :
Code: Select all
upline1=k_page_id / name / title

but the relation upline1 still remain empty.

And for the upline2 & upline3, can it picked randomly?

Thx!
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
Some update :

I got it work. Totally change the code, not use route. And use gpc to get the upline id from url :
Code: Select all
<!-- start upline1 -->
                        <div class="unit" style="display : none;">
                           <div class="input login-input">
                              <label class="icon-left" for="login">
                                 <i class="zmdi zmdi-account"></i>
                              </label>
                              <cms:input class='form-control login-frm-input' type="text" name='pin_upline1' label='PIN Upline 1' value="<cms:pages masterpage='member/index.php' custom_field="pin=<cms:gpc 'upline' method='get' />" limit='1'><cms:show k_page_id /></cms:pages>" required='1' validator_msg='required=PIN tidak terdaftar atau salah!' />
                           </div>
                        </div>
                        <!-- end upline1 -->


So to register, user need to access url :
Code: Select all
http://site-name/member/daftar.php?upline=xx0001



So, the upline 1 solved.

Still need help how to get upline 2 & upline 3 randomly from relation bound.

I hope someone can help me ;)


Thx!
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
Hi,

<cms:pages>, <cms:related_pages>, <cms:reverse_related_pages> all support 'random' as one of the values the 'orderby' parameter takes e.g.
<cms:pages orderby='random' limit='5'>..

I suppose you could use that to get the random values you need.
Does it help?
KK wrote: Hi,

<cms:pages>, <cms:related_pages>, <cms:reverse_related_pages> all support 'random' as one of the values the 'orderby' parameter takes e.g.
<cms:pages orderby='random' limit='5'>..

I suppose you could use that to get the random values you need.
Does it help?


Hi KK.

Ok, i will try create an editable type dropdown on databound and fetch id from relation via cms:pages with random order.

Will try tomorow at office, and touch you back soon after i get the result.

Indeed it help me alot KK.

Thx!
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
Ok, here is the result :

I create 3 editable :
Code: Select all
<cms:input class='form-control login-frm-input' type="text" name='pin_upline1' label='PIN Upline 1' value="<cms:pages masterpage='member/index.php' custom_field="pin=<cms:gpc 'upline' method='get' />" limit='1'><cms:show k_page_id /></cms:pages>" required='1' validator_msg='required=PIN tidak terdaftar atau salah!' />


<cms:input class='form-control login-frm-input' type="text" name='pin_upline2' label='PIN Upline 2' value="<cms:pages masterpage='member/index.php' custom_field="pin!==<cms:gpc 'upline' method='get' />" orderby='random' limit='1'><cms:show k_page_id /></cms:pages>" required='1' validator_msg='required=PIN tidak terdaftar atau salah!' />


<cms:input class='form-control login-frm-input' type="text" name='pin_upline3' label='PIN Upline 3' value="<cms:pages masterpage='member/index.php' custom_field="pin!==<cms:gpc 'upline' method='get' />" orderby='random' limit='1'><cms:show k_page_id /></cms:pages>" required='1' validator_msg='required=PIN tidak terdaftar atau salah!' />



This is the registration url format :
Code: Select all
http://site-name/member/daftar.php?upline=xx0001


The "pin_upline1" will get the value from "?upline=xxxx" and send it to "<cms:pages />" that give id filtered by editable region :
Code: Select all
<cms:editable
         name='pin'
         label='PIN'
         type='text'
         order='9'
      />



And the "pin_upline2" & "pin_upline3" will fetch random id that not contain "pin_upline1" value.

The Problem is "pin_upline2" can fetch id that same with "pin_upline3" (vice-versa).

Can i filter the output of "pin_upline2" that not contain "pin_upline3" randomly? (vice-versa).


Thx!
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
I think you can save the ID used in upline2 and then explicitly instruct upline3 to exclude it.
For example as follows -
Code: Select all
<cms:set my_upline2_id="
<cms:pages masterpage='member/index.php' custom_field="pin!==<cms:gpc 'upline' method='get' />" orderby='random' limit='1'><cms:show k_page_id /></cms:pages>"
/>

<cms:input type="text" name='pin_upline2' value="<cms:show my_upline2_id />"  />

<cms:input type="text" name='pin_upline3' id="NOT <cms:show my_upline2_id />" value="<cms:pages masterpage='member/index.php' custom_field="pin!==<cms:gpc 'upline' method='get' />" orderby='random' limit='1'><cms:show k_page_id /></cms:pages>" />

Hope it helps.
KK wrote: I think you can save the ID used in upline2 and then explicitly instruct upline3 to exclude it.
For example as follows -
Code: Select all
<cms:set my_upline2_id="
<cms:pages masterpage='member/index.php' custom_field="pin!==<cms:gpc 'upline' method='get' />" orderby='random' limit='1'><cms:show k_page_id /></cms:pages>"
/>

<cms:input type="text" name='pin_upline2' value="<cms:show my_upline2_id />"  />

<cms:input type="text" name='pin_upline3' id="NOT <cms:show my_upline2_id />" value="<cms:pages masterpage='member/index.php' custom_field="pin!==<cms:gpc 'upline' method='get' />" orderby='random' limit='1'><cms:show k_page_id /></cms:pages>" />

Hope it helps.


I can confirm this is solved!

Thx KK for the help!
Big appreciate!


Thx!
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
You are welcome :)
Thanks for letting me know.
8 posts Page 1 of 1