@KK Sir,
Does this answer your query?
Thanks a lot sir. your reply indeed answered my query. And helped me implement my use case.
I think the name 'list_view' is bothering you

The list_view word was the confusion creator as you mentioned! Very silly of me! Thanks for understanding my issue sir!
I have another question though.
In the success condition, I want to achieve two things:
1. Redirect to the list view
2. open an app
the #2 works but the #1 doesnot. Nevertheless, the clonable page is created in the backend.
My create_view code is:
- Code: Select all
<!-- This code is placed in the php file of the routable template -->
<cms:set submit_success="<cms:get_cookie 'ctr_submit_success' />" />
<cms:delete_cookie 'ctr_submit_success' />
<cms:if submit_success >
<div class="toast-container position-fixed top-0 start-50 translate-middle-x p-3" >
<div class="toast align-items-center text-white border-0 toast-success bg-success" role="alert" aria-live="assertive" aria-atomic="true" data-bs-delay="3000">
<div class="d-flex">
<div class="toast-body">
<cms:show "Success! Redirecting to WhatsApp." />
</div>
<button type="button" class="btn-close me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
<cms:pages masterpage=k_template_name id="<cms:show submit_success />" limit='1' show_future_entries='1'>
<cms:php>
global $indate_encode;
global $outdate_encode;
global $message_encode;
$indate_encode = urlencode("<cms:date ctr_indate format='M d, Y H:i' />");
$outdate_encode = urlencode("<cms:date ctr_outdate format='M d, Y H:i' />");
$message_encode = urlencode("<cms:show message_text />");
</cms:php>
<cms:set url_ctr_indate="<cms:php>global $indate_encode;echo $indate_encode;</cms:php>" scope="global" />
<cms:set url_ctr_outdate="<cms:php>global $outdate_encode;echo $outdate_encode;</cms:php>" scope="global" />
<cms:redirect url="whatsapp://send/?phone=<cms:related_pages 'ctr_isd'><cms:show country_isd /></cms:related_pages><cms:show ctr_mobile />&text=Dear%20<cms:show ctr_name />%2C%0a%20Thanks%20for%20enquiring%20with%20us%20for%20the%20dates%20<cms:if ctr_indate><cms:show url_ctr_indate /></cms:if>%20to%20<cms:if ctr_outdate><cms:show url_ctr_outdate /></cms:if>.%20Our%20price%20is%20%E2%82%B9<cms:show ctr_pricequoted />%20%28excluding%20GST%29.%0A%20Additional%20message" />
</cms:pages>
</cms:if>
<!-- This code is placed in the php file of the routable template -->
<!-- Form -->
<cms:form
masterpage=k_template_name
mode='create'
enctype='multipart/form-data'
method='post'
anchor='0'
>
<cms:if k_success >
<cms:set my_data='[]' is_json='1' />
<cms:capture into='my_data.' is_json='1' scope='parent'>
{
"message_text" : <cms:escape_json><cms:show frm_message_text2 /></cms:escape_json>
}
</cms:capture >
<cms:php>
global $php_ctr_name;
$php_ctr_name = urlencode("<cms:show frm_ctr_name />");
</cms:php>
<cms:db_persist_form
_invalidate_cache='0'
_auto_title='1'
ctr_owner = "<cms:show k_user_id />"
ctr_name = "<cms:php>global $php_ctr_name; echo $php_ctr_name;</cms:php>"
ctr_message = my_data
ctr_status="Pending"
/>
<cms:if k_success>
<cms:set_cookie name='ctr_submit_success' value='<cms:show k_last_insert_id />' />
<cms:redirect url="<cms:route_link 'list_view' />" />
</cms:if>
</cms:if>
<cms:if k_error >
<div class="toast-container position-fixed bottom-0 start-50 translate-middle-x p-3" >
<cms:each k_error>
<div class="toast align-items-center text-white border-0 toast-error bg-danger" role="alert" aria-live="assertive" aria-atomic="true" data-bs-delay="3000">
<div class="d-flex">
<div class="toast-body">
<cms:show item /><br>
</div>
<button type="button" class="btn-close me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</cms:each>
</div>
</cms:if>
<div class="row">
<div class="col-12 col-md-4">
<div class="mb-3">
<label for="ctr_name" class="gxcpl-subtitle-2">First Name</label>
<cms:input name="ctr_name" id="ctr_name" type="bound" class="form-control" placeholder="" />
</div>
</div>
<div class="col-12 col-md-4">
<label for="ctr_mobile" class="gxcpl-subtitle-2">ISD Code and Mobile</label>
<div class="input-group mb-3">
<cms:hide>
<cms:input name="ctr_isd" id="ctr_isd" type="bound" />
</cms:hide>
<select class="js-example-basic-single form-select" name="f_ctr_isd" id="f_ctr_isd" style="width:50%" >
<option value="-" selected disabled>Country</option>
<cms:pages masterpage="support-files/import-country.php" order="asc" orderby="country_name">
<option value="<cms:show k_page_id />" data-id="<cms:show country_isd />">
<span class="flag-icon <cms:show country_flag/>"></span> <cms:show country_name /> (+<cms:show country_isd />)
</option>
</cms:pages>
</select>
<cms:hide>
<cms:input name="ctr_mobile" id="ctr_mobile" type="bound" />
</cms:hide>
<input name="f_ctr_mobile" id="f_ctr_mobile" type="tel" class="form-control" placeholder="" />
</div>
</div>
<div class="col-12 col-md-4"></div>
<div class="col-12 col-md-4">
<div class="mb-3">
<label for="ctr_indate" class="gxcpl-subtitle-2">In Date</label>
<cms:hide>
<cms:input name="ctr_indate" type="bound" />
</cms:hide>
<input name="f_ctr_indate" id="f_ctr_indate" type="datetime-local" class="form-control" placeholder="" />
</div>
</div>
<div class="col-12 col-md-4">
<div class="mb-3">
<label for="ctr_outdate" class="gxcpl-subtitle-2">Out Date</label>
<cms:hide>
<cms:input name="ctr_outdate" type="bound" />
</cms:hide>
<input name="f_ctr_outdate" id="f_ctr_outdate" type="datetime-local" class="form-control" placeholder="" />
</div>
</div>
<div class="col-12 col-md-4">
<div class="mb-3">
<label for="ctr_pricequoted" class="gxcpl-subtitle-2">Price Quoted</label>
<cms:input name="ctr_pricequoted" id="ctr_pricequoted" type="bound" class="form-control" placeholder="" />
</div>
</div>
<div class="col-12 col-md-12">
<div class="mb-3">
<label for="message_text2" class="form-label">Message</label>
<cms:input name="message_text2" class="form-control" type="textarea" />
</div>
</div>
<div class="col-12 col-md-12 text-center">
<button class="btn btn-primary gxcpl-button" type="submit" >
<i class="fa fa-whatsapp fa-lg"></i> WhatsApp
</button>
</div>
</div>
</cms:form>
<!-- Form -->
By what I have understood over time, the k_success block (as under):
- Code: Select all
<cms:if k_success>
<cms:set_cookie name='ctr_submit_success' value='<cms:show k_last_insert_id />' />
<cms:redirect url="<cms:route_link 'list_view' />" />
</cms:if>
Would set a cookie and redirect to the list view and in the list view the cookie will be set, conditional statement will be executed. But, in my case here, I am having two processes in the conditional statement:
1. displays a toast message
2. opens a mobile app
The issue i am battling with right now is that after saving the form, the clonable page with all data is created, and the app is opened, but the form remains on the create_view only. It doesnot go to the list view. So when I return from the app I see the create view with all the data I had filled in.
Does the cms:redirect in the conditional statement make an issue? but I feel that the cms:redirect comes after the first redirection so it should not be creating the issue, i may be wrong though.
So I am confused as to why there is no redirection yet the app to be opened is opened and displayed with all the pre-filled message fields. Could you help me with this too sir.
Regards,
GXCPL (Priya)
FYI, I am doing a webview app for android which requires the app to be opened using the following link:
- Code: Select all
whatsapp://send/?phone=<cms:related_pages 'ctr_isd'><cms:show country_isd /></cms:related_pages><cms:show ctr_mobile />&text=Dear%20<cms:show ctr_name />%2C%0a%20Thanks%20for%20enquiring%20with%20us%20for%20the%20dates%20<cms:if ctr_indate><cms:show url_ctr_indate /></cms:if>%20to%20<cms:if ctr_outdate><cms:show url_ctr_outdate /></cms:if>.%20Our%20price%20is%20%E2%82%B9<cms:show ctr_pricequoted />%20%28excluding%20GST%29.%0A%20Additional%20message"
Can this be done with the cms:curl tag as mentioned here, in place of the cms:redirect tag, if at all the second cms:redirect is creating the issue of the page not redirecting to the list view.