Problem switching page in addon

I have developed some addons but facing only one problem, from backend when i go to any page of my addon from menu it display correct central menu at top, but from my addon page while submitting form all menu items vanished.
I am attaching screenshot for reference.
please help me why it happening.

At first, try to clear cache. Usually it helps

Hi @ecomlabs
I am sorry I think i could not explain properly.
I beleave i have to understand tpl file properly because if we remove capture command as per screenshot nothing display on page after reloading, but when i put capture command i can see all other contents but menu is not visible.
But normally its not happening, it happen when I submit forum to a dispatch location and in php I have mode = “something” and similarly i have TPL file name “something.tpl”
after getting all forum fields and doing required php process this tpl file doesn’t display menu.

Your help will be highly appriciated

It is required to examine issue directly on your store. Looks like something wrong with permissions

@ecomlabs I beleave something missing in form submission, when I am submitting a forum using this code

{capture name="mainbox"}
<form action="{"cb_import_products.update"|fn_url}" method="post"  name="shopify" enctype="multipart/form-data">  
<label for="skey">Shopify API Key:</label>
  <input type="text" id="skey" name="skey"><br><br>
  <label for="spassword">Password/Access token:</label>
  <input  type="password" id="spassword" name="spassword"><br><br>
  
  <label for="sshopname">Shop Url:</label>
  <input type="text" id="sshopname" name="sshopname"><br><br>
  
  <input type="submit" value="Submit">
</form>
{/capture}
{include file="common/mainbox.tpl" title="Shopify" buttons=$smarty.capture.buttons content=$smarty.capture.mainbox}

when i click on submit it will run cb_import_products.update dispatch mode and after reloading it will display backend screen without menu, screenshot and code of that page already shown in previous message.

but in other case if i simply refresh cb_import_products.update dispatch mode it displays the menu also.
I think some problem during submitting form.
Hope you are experienced and can guide me.

How do you process post request in the controller? What result does it return?

@ecomlabs Its a long code but I don’t think there is any issue with it because I have tested this with empty mode as well. like below.

<?php

use Tygh\Enum\YesNo;
use Tygh\Registry;
error_reporting (E_ALL ^ E_NOTICE);
error_reporting (E_ALL ^ E_WARNING);
if (!defined('BOOTSTRAP')) { die('Access denied'); }
if ($mode == 'empty') {
    // Same result even mode is empty
}
?>

even there is nothing in mode I am getting same result menu is not visible.
I am worried about it, if i use cm-ajax it can be fixed but i can’t use ajax here due to some reason.
please let me know what is issue.

Try to use the following code for the post requests

@ecomlabs
I have not tested but I beleave your controller_status_redirect will work but here 2 things are important.
1= I can’t always redirect page because i want to display some data based on form submission which is not stored anywhere when mode is running so it should display without redirecting the page.
2= what is proper way to submit form in cs cart, using tpl file and php $mode, should be some way to do it.

Thank you

Do you want to display it in the popup or somewhere on the current page?

Yes, the template and controller is right way. But there can be various actions after the form is submitted

  • redirect to the “thank you” page
  • default notification with “thank you” message
  • popup with “thank you” text
  • show extra content (e.g. “thank you” text) on the same page

@ecomlabs
leave the 2nd one but again i am explaining 1st below.
1= my question was that “if a mode is running and we have some data to display at the end of mode than we can’t redirect it to another page otherwise we will lose the data which we was storing in running mode, in this case how can we keep the menu on top, keep stored data and display the page with menu as i already explained my issue in my first 2 messages”

in short I want to run a mode and tpl file and on submission of form the menu is vanished which i don’t want, need solution for this.

Just store required data is session and perform redirect