Jump to content


Photo

Omit page filename omits folder.


took a sharp eye and some debug to find/figure this.
If one Omits the Page file-name from a file in a folder, when visiting that page 2 things occur, 1 expected:
A:(expected Behaviour)ipsRegistry::getClass('ccsFunctions')->getPageName() is empty
B:(undesired behaviour, bug)ipsRegistry::getClass('ccsFunctions')->getFolder() is empty.
This makes it programatically difficult or impossible to tell the difference between
http://mysite.com/
and
http://mysite.com/folder/

Status: Fixed
Version: 2.3.1
Fixed In: 2.3.2


6 Comments

...uck this goes worse.
getPageName returns the folder in this situation, but without the preceding / on the directory.... its acting as if i made a page with the file-name of the folder, not like I made a folder and put an index file within it.

...uck this goes worse.getPageName returns the folder in this situation, but without the preceding / on the directory.... its acting as if i made a page with the file-name of the folder, not like I made a folder and put an index file within it.

ergo... can we do the sane thing and set the value of this method directly from the resulting page data or something? this sniffing occurring is hardly accurate when you very basically have the page data already at said point.

ergo... can we do the sane thing and set the value of this method directly from the resulting page data or something? this sniffing occurring is hardly accurate when you very basically have the page data already at said point.

Natch, reconstructing off URL.
problem is here, line ~630 at ccsFunctions->_getPageAndFolder:
  $uriBits = explode( '/', $_path );
  $myFolder = '';
  if( count($uriBits) > 1 )
  {
   $page  = array_pop($uriBits); // Retrieve the file name
   $myFolder = count($uriBits) ? '/' . implode( '/', $uriBits ) : '';
   $myFolder = ( $myFolder == '/' ) ? '' : $myFolder;
  }
  else
  {
   $page  = $_path;
  }
  $folder = $myFolder;
this all boils down to this explicitly...Say I have an array of page data. In this configuration(index page inside a folder) with furls on, this is literally the only time(simplified example, ofc i check that these return a value and act accordingly):
$r['page_folder'].$r['page_seo_name']!=$this->registry->getClass('ccsFunctions')->getFolder().$this->registry->getClass('ccsFunctions')->getPageName()
and without the / on the page name that should be a folder, no amount of fiddling from my end will make it work correctly across all index pages.
here... this highlights the problem and can be used as debug.
Make an index page in a folder... omit file-name, raw PHP page... contents:
print $this->registry->ccsFunctions->returnPageUrl( array('page_seo_name' => $this->registry->ccsFunctions->getPageName(), 'page_folder' => $this->registry->ccsFunctions->getFolder(), 'page_id' => '0' ));
print '<br />Page: ';
print $this->registry->ccsFunctions->getPageName();
print '<br />Folder: ';
print $this->registry->ccsFunctions->getFolder();
the URL Generated is Slightly wrong as well... likely because of the page is folder issue.
That method in the library has absolutely no way at this point in the input to know if /folder is a page or a folder, and assumes it is a page (as you have seen). The pages.php module accounts for this. There is just no way for the input parser to know what is going on at this point (as an aside...if you had a page named "folder" with no extension in your first example, that would be loaded instead of the index.* inside /folder).

I've added methods so you can override the automatically sniffed data.

/**
     * Programatically set folder
     *
     * @param    string    Folder to set
     * @return    @e void
     * @link    http://community.invisionpower.com/tracker/issue-37244-omit-page-filename-omits-folder/
     * @note    IP.Content does not use this method, it is here only for developers facing issues due to the bug report linked
     */
    public function setFolder( $folder='' )
    {
        $this->folder    = $folder;
    }

    /**
     * Programatically set page
     *
     * @param    string    Page to set
     * @return    @e void
     * @link    http://community.invisionpower.com/tracker/issue-37244-omit-page-filename-omits-folder/
     * @note    IP.Content does not use this method, it is here only for developers facing issues due to the bug report linked
     */
    public function setPage( $page='' )
    {
        $this->page        = $page;
    }