Hello,
It's possible to tell where is my error.
I created a new files blog_content.php (see an article) and create a new add on in pages_modules called blog_content.php
When I want to see my article, I have a page not found :
Quote
The requested URL /boutique/comportements-multicanaux-etudes-decouvrir-bl-26.html was not found on this server.
my original url :
http://www.mysite.com/boutique/blog_content.php?blog_content_id=26
Thanks.
Process :
I write in ht access this line :
RewriteRule ^([a-z0-9/-]+)-bl-([0-9]+).html$ blog_content.php [NC,L,QSA]
and I write this module :
class Blog_Content_Page_Module extends aPage_Modules {
private static $_singleton = null;
/**
* Array of _GET key dependencies for this page
* - marker is the seo url replacement for the dependent _GET key ( e.g. -c- replaces cPath )
* - query is the query used to extract the link text from the database
* - to_replace is an array of texts that are to be replace with real values in the query
* @example protected $dependencies = array( 'cPath' => array( 'marker' => '-c-',
* @var array $dependencies
*/
// 'query' => "SELECT pd.blog_content_name FROM :TABLE_BLOG_CONTENT_DESCRIPTION pd INNER JOIN :TABLE_BLOG_CONTENT p ON pd.blog_content_id = p.blog_content_id WHERE pd.blog_content_id=':blog_content_id' AND pd.language_id=':languages_id' LIMIT 1",
protected $dependencies = array( 'blog_content_id' => array( 'marker' => '-bl-',
'query' => "SELECT pd.blog_content_name FROM :TABLE_BLOG_CONTENT_DESCRIPTION pd where pd.blog_content_id=':blog_content_id' AND pd.language_id=':languages_id' LIMIT 1",
'to_replace' => array( ':TABLE_BLOG_CONTENT_DESCRIPTION', ':TABLE_BLOG_CONTENT', ':blog_content_id', ':languages_id' ) ) );
/**
* The current dependency key extracted from the incoming parameters
*
* @var string $key - dependency key
*/
protected $key = null;
/**
* extracts the key => value pairs from the querystring in order to build a unique cache name for the loaded page
*
* @var array $cache_name_builder
*/
// protected $cache_name_builder = array( 'blog_content_id' => 1, 'reviews_id' => 1 ); // xxx = _GET key ( e.g. cPath ), you may want to add "page" if there are paging functions
protected $cache_name_builder = array( 'blog_content_id' => 1); // xxx = _GET key ( e.g. cPath ), you may want to add "page" if there are paging functions
/**
* Class constructor
* @access private
*/
private function __construct() {
} // end constructor
/**
* Returns a singleton instance of this object
*
* @access public
* @return Blog_Content_Page_Module
*/
public static function i() {
if ( !self::$_singleton instanceof self ) {
self::$_singleton = new self;
}
return self::$_singleton;
} // end method
/**
* Retrieve the dependencies array for this page module
*
* @access public
* @return array $dependencies
*/
public function retrieveDependencies() {
return $this->dependencies;
}
/**
* Acquire an array of single or multiple link texts from the query
* this will be cached for later retrieval.
*
* @see Usu_Main::query()
* @uses trim()
*
* @access protected
* @return array array of link test
*/
protected function acquireLinkText() {
$result = Usu_Main::i()->query( $this->query );
$text_array = tep_db_fetch_array( $result );
tep_db_free_result( $result );
if ( false === $text_array ) {
return false;
}
$final_text_array = array();
foreach ( $text_array as $key => $text ) {
if ( tep_not_null( trim( $text ) ) ) {
$final_text_array[$key] = $text;
}
}
// We will cache this result
return $final_text_array;
}
/**
* The main method of this class that receives input needed to build a link
* then finally returns a fully built seo link if it has not previousluy returned false.
*
* @see Usu_Main::getVar()
* @see Usu_Main::setVar()
* @see aPage_Modules::stripPathToLastNumber()
* @see aPage_Modules::setQuery()
* @see aPage_Modules::unsetProperties()
* @see aPage_Modules::getDependencyKey()
* @see aPage_Modules::setAllParams()
* @see aPage_Modules::validRequest()
* @see aPage_Modules::returnFinalLink()
* @param string $page - valid osCommerce page name
* @param string $parameters - querystring parameters
* @param bool $add_session_id - true / false
* @param string $connection - NONSSL / SSL
* @param array $extract - array of _GET keys to remove from the querystring or bool false to do nothing
* @uses trigger_error()
* @throws - triggers an error of type E_USER_WARNING for an incorrect or inexistant dependency key
* @access public
* @return bool false - forces the system to return the standard osCommerce link wrapper
* @return string - fully built seo url
*/
public function buildLink( $page, $parameters, $add_session_id, $connection ) {
$extract = array( 'blog_content_id' );
$this->setAllParams( $page, $parameters, $add_session_id, $connection, $extract );
if ( false === $this->validRequest() ) {
$this->unsetProperties();
return false;
}
$this->key = $this->getDependencyKey();
/**
* If the shop has issues it may pass in null values, in this case return false to force the standard osCommerce link wrapper
*/
if ( !array_key_exists( $this->key, $this->keys_index ) || !tep_not_null( $this->keys_index[$this->key] ) ) {
return false;
}
// Switch statement where the correct query and query marker replacements to use are selected via the _GET key detected
switch ( true ) {
case $this->key == 'blog_content_id': // xxx = _GET key ( e.g. cPath )
// This array contains replacements for the to_replace array ( see the $dependencies array )
$this->setQuery( array( TABLE_BLOG_CONTENT_DESCRIPTION, TABLE_BLOG_CONTENT, $this->stripPathToLastNumber( $this->keys_index[$this->key] ), Usu_Main::i()->getVar( 'languages_id' ) ) );
break;
default:
trigger_error( __CLASS__ . '::' . __FUNCTION__ . ' Incorrect or inexistant dependency key.', E_USER_WARNING );
break;
} // end switch
$link_text = $this->acquireLinkText();
// If the query returned false then we return nothing and set $page_not_found to true forcing a 404 page
Usu_Main::i()->setVar( 'page_not_found', false );
if ( false === $link_text ) {
Usu_Main::i()->setVar( 'page_not_found', true );
$this->unsetProperties();
return;
}
// Return a fully built seo url
return $this->returnFinalLink( Usu_Main::i()
->getVar( 'uri_modules', USU5_URLS_TYPE )
->createLinkString( $this->page, Usu_Main::i()
->getVar( 'uri_modules', USU5_URLS_TYPE )
->separateUriText( $this->linktext( $link_text ) ), $this->dependencies[$this->key]['marker'], $this->keys_index[$this->key] ) );
} // end method
} // end class
Edited by Gyakutsuki, 09 August 2011 - 02:35 PM.