Jump to content

how to get admin link from tpl file


Recommended Posts

I'm using prestashop 1.5.6, i has problem with getting admin controller link.

 example:

In controller:

$this->context->smarty->assign(
   	   			array(
   	   					"data" => $this->inputData['PS_SOLRBRIGHT_INDEX_ENGLISH'],
   	   					"url" => $this->context->link->getAdminLink('SolrBrigdeIndex'),
        	
        	)
        );

but the tpl file it display:

 index.php?controller=SolrBrigdeIndex&token=db1d79f3f87e3d378bf632a1f851df38 

the same below is true.

http://localhost:81/prestashop/admin123/index.php?controller=SolrbrigdeIndex&token=db1d79f3f87e3d378bf632a1f851df38 

but i can't get the same. please help me. thank!

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

Is it a back office controller? If not, you have to manually write the name of the admin folder, it's not saved anywhere (in a constant, actually, yes, but it's not assigned in the front office anyway)

yes it's a back office controller, i use custom template for this controller.

Link to comment
Share on other sites

Well then, using that link should lead you to the back office itself, no? It's a relative link so you should be redirected to the same path

if i use in tpl this is ok, but i want to get this url and put it on jquery: the same

$(document).ready(function() {
		$('#desc-configuration-save').hide();
		$('input').click(function(){
			window.location.href = {$url};
				
			});
	});

it not work!

Link to comment
Share on other sites

  • 4 weeks later...

 

I'm sorry could you say how you got the link to your controller. 
I have your same problem with my controller on my form, I can not figure out how to call it in the tpl file. 
I get to use: dirname (miocontroller), but does not work

 

$this->context->smarty->assign(array('link' => $this->context->link->getAdminLink('your admincontroller',false)))

you assign this into smarty and in .tpl file you get it.

or

if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'){
   			$urls = 'https://';
   		}
   		else{
   			$urls = 'http://';
   		}
   		$url = $urls.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);

then you combine with link got above.

Sorry for english.

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

×
×
  • Create New...