简体   繁体   中英

Error link url JPATH_SITE in php joomla?

I have a error:

http://www.test.com/downloads/

in Joomla I call function

$savepath = JPATH_SITE.DS.'downloads';

But when put $savepath on tag a is link url become:

<a href="<?php echo savepath?>">test</a>

=> firebug is url is test.com/home/test/public_html/downloads/ How to fix this error to result is:

test.com/downloads

Or

/home/test/public_html/downloads/ 

change this:

<a href="<?php echo savepath ?>">test</a>

to this:

<a href="<?php echo $savepath ?>">test</a>

Or you could always use the relative path such as:

$savepath = JURI::root() . "/downloads"
<a href="<?php echo $savepath ?>">test</a>

JPATH_SITE is not your site's URL it's the filesystem path of your installation. Instead use this:

$savepath = JUri::root() . 'downloads';
<a href="<?php echo $savepath?>">test</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM