Jump to content

[solved] My-account, include file instead of links


Recommended Posts

Hi !

 

I wonder if it is possible to include files like address.tpl, identity.tpl etc... to have all informations on the my-account template instead of links ?

 

As it is by default of course it's not because the controller is missing so the tpl doesn't display correctly.

 

Thanks :)

Link to comment
Share on other sites

  • 2 weeks later...

Hi there,

 

I don't understand why it's not working.

 

For example if I include addresses.tpl, it says that this customer has no addresses but if i clink on the default link to the TPL it's working.

 

In those two cases, the URL remain the same ...

 

Someone has an explanation ?

 

Thanks

Link to comment
Share on other sites

Ok, found a solution.

 

I modified my-account.tpl like this:

{capture name=path}{l s='My account'}{/capture}
<h1 >{l s='My account'}</h1>
{if isset($account_created)}
<p class="success">
 {l s='Your account has been created.'}
</p>
{/if}
{if $has_customer_an_address}
{include file="$tpl_dir./address.tpl" }
{/if}
{include file="$tpl_dir./history.tpl"}
{if $returnAllowed}
{include file="$tpl_dir./order-follow.tpl"}
{/if}
{include file="$tpl_dir./order-slip.tpl"}
{include file="$tpl_dir./addresses.tpl"}
{include file="$tpl_dir./identity.tpl"}
{if $voucherAllowed}
{include file="$tpl_dir./discount.tpl"}
{/if}

 

and MyAccountController.php like this :

class MyAccountControllerCore extends FrontController
{
public $auth = true;
public $php_self = 'my-account';
public $authRedirection = 'my-account';
public $ssl = true;
public function setMedia()
{
 parent::setMedia();
 $this->addCSS(_THEME_CSS_DIR_.'my-account.css');
 $this->addCSS(_THEME_CSS_DIR_.'addresses.css');
 $this->addJS(_THEME_JS_DIR_.'tools.js');
 $this->addJS(_THEME_JS_DIR_.'tools/statesManagement.js');
 $this->addCSS(_THEME_CSS_DIR_.'history.css');
 $this->addJqueryPlugin('scrollTo');
 $this->addJS(_THEME_JS_DIR_.'history.js');
}
/**
 * Assign template vars related to page content
 * @see FrontController::initContent()
 */
public function initContent()
{
 parent::initContent();
 $AddressesControllerCore = new AddressesControllerCore();
 $AddressControllerCore = new AddressControllerCore();
 $HistoryControllerCore = new HistoryControllerCore();
 $OrderFollowControllerCore = new OrderFollowControllerCore();
 $OrderSlipControllerCore = new OrderSlipControllerCore();
 $IdentityControllerCore = new IdentityControllerCore();
 $DiscountControllerCore = new DiscountControllerCore();
 $has_address = $this->context->customer->getAddresses($this->context->language->id);
 $this->context->smarty->assign(array(
  'has_customer_an_address' => empty($has_address),
  'voucherAllowed' => (int)CartRule::isFeatureActive(),
  'returnAllowed' => (int)Configuration::get('PS_ORDER_RETURN')
 ));
 $this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Hook::exec('displayCustomerAccount'));
 $AddressesControllerCore->initContent();
 $AddressControllerCore->initContent();
 $HistoryControllerCore->initContent();
 $OrderFollowControllerCore->initContent();
 $OrderSlipControllerCore->initContent();
 $IdentityControllerCore->initContent();
 $DiscountControllerCore->initContent();

 $this->setTemplate(_PS_THEME_DIR_.'my-account.tpl');
}
}

Edited by cedricpdp (see edit history)
Link to comment
Share on other sites

  • 4 months later...
×
×
  • Create New...