Announcement

  •  » Engine
  •  » PHPWG_ROOT_PATH constant

#1 2010-10-21 23:39:44

grum
Former Piwigo Team
Pantin
2007-09-10
1371

PHPWG_ROOT_PATH constant

PHPWG_ROOT_PATH constant is declared to be equal to ./
why not.

But this constant is used in both the PHP code to the includes file
example : lines 26-27 from file index.php

Code:

include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
include(PHPWG_ROOT_PATH.'include/section_init.inc.php');

and used to to build url
example : lines 30-49 from file include/functions_url.inc.php

Code:

function get_root_url()
{
  global $page;
  if ( isset($page['root_path']) )
  {
    $root_url = $page['root_path'];
  }
  else
  {// TODO - add HERE the possibility to call PWG functions from external scripts
    $root_url = PHPWG_ROOT_PATH;
  }
  if ( strncmp($root_url, './', 2) != 0 )
  {
    return $root_url;
  }
  else
  {
    return (string)substr($root_url, 2);
  }
}

It's a little bit disturbing ... : - /
For me, a file on the server and url are two different things...


My pictures with Piwigo, of course !
[ www.grum.fr ]

Offline

 

#2 2010-11-04 21:34:26

stellablue
Member
Hawaii
2010-10-25
14

Re: PHPWG_ROOT_PATH constant

I too am a little confused about  this  Constant PHPWG_ROOT_PATH always being ./  .   I am new to piwigo and am trying to learn more about themes and plug-in development.   Maybe someone can explain this Constant.

Would it not be a bit better to have a function that returns a complete URL (or PATH) and concat with literal string or variable?  Everything being relative is confusing to follow, albeit technically correct.  I think WordPress uses complete URLS (paths) based on domain, install path etc.  look at source code on a WP page and you will likely find no relative URLs.

With the relative URLs (paths) the browser (or os) has to parse and compute final path, whereas a complete URL (path) needs no parsing, so resources may load faster.  It probably is not a significant amount of time, but some.

- stellablue

Offline

 

#3 2010-11-09 01:06:01

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: PHPWG_ROOT_PATH constant

stellablue wrote:

Would it not be a bit better to have a function that returns a complete URL (or PATH) and concat with literal string or variable?  Everything being relative is confusing to follow, albeit technically correct.  I think WordPress uses complete URLS (paths) based on domain, install path etc.  look at source code on a WP page and you will likely find no relative URLs.

I don't know if that's related or if it's still true today, but I remember big problems when moving a WordPress from a place to another. With Piwigo, that is not a problem at all.

In the source code of your plugin, you have to use the make_index_url() or make_picture_url() functions. This is the only way to produce correct Piwigo URL : don't try to guess the URL of a given category, because you don't know if another user will use the same settings for URL style, if he will use a permalink or not and so on.

stellablue wrote:

With the relative URLs (paths) the browser (or os) has to parse and compute final path, whereas a complete URL (path) needs no parsing, so resources may load faster.  It probably is not a significant amount of time, but some.

I truly hope relative URL make no difference with absolute URL, at speed level. If you find any documentation related to this issue, I'm interested.


stellablue wrote:

I am new to piwigo and am trying to learn more about themes and plug-in development.

Open a new discussion for each question you have related to theme or plugin development. We must improve the documentation and discussion with a new plugin developper will make obvious what really need to be documented, and how to document it.

Offline

 

#4 2010-11-09 20:06:05

stellablue
Member
Hawaii
2010-10-25
14

Re: PHPWG_ROOT_PATH constant

Hi Plg,

plg wrote:

use the make_index_url() or make_picture_url() functions...I truly hope relative URL make no difference with absolute URL, at speed level. If you find any documentation related to this issue, I'm interested.

OK, will do.  The browser parses urls in a document and converts them to complete urls (and resolves any DNS if different domain and DNS is cached for speed).  So, the performance hit is on client side and is minimal and developers don't consider it compared to the weighty decision of absolute or relatives URLs.  I understand there was an version of IE that was double loading some resources...but I forget what an IE is or was LOL ;-)


BTW, I have moved wordpress between folders and servers and had success, but wp core is pretty good, I use atahualpha theme mostly which is well written.  However it can breakdown if you use absolute links in your posts / widgets and move your site, and poorly written themes or plugins that cannot tolerate a folder different than installation can lead to issues.

I am working on a new theme for piwigo and have written 3 plugins :-).  The plug-ins are: pAnchor, defines html page anchor and appends #anchorname to URLs for smoother browsing and slideshow; pGravatar, implements gravatar for comments; fsSlideShow integrates SlideShowPro with piwigo for impressive full screen  HD slideshow.

After I hacked my first piwigo install...posted here, I took plg advice and am 'working within the system'  to achieve result with modifying any core files.  And I must say I am impressed at piwigo and smarty.   I have a few specific questions and will post in separate topics.

Thanks - stellablue

Last edited by stellablue (2010-11-09 20:09:17)

Offline

 
  •  » Engine
  •  » PHPWG_ROOT_PATH constant

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact