Often I find X-Cart store owners which have had a custom module developed for X-Cart.
One such store owner, had a module developed for managing Questions & Categories.
The Questions part of the module, was stored in the database & managed in X-Cart administration, similar to normal X-Cart Products.
Similarly, the Question Categories were similar to X-Cart Categories.
URLs for each section originally look like so:
Question: question.php?qid=123
Question Category: home.php?qcat=123
While such URLs can easily be manually rewritten, using XCSEO Pro's Manual URL feature, that process is of course, very manual.
This particular store owner wanted to have the process of rewriting his URLs to be more automated (to have each url auto-generated by default), similar to how XCSEO Advanced and Pro handle Products, Categories, etc.
The solution, is to extend XCSEO's class. This process is very simple.
There are 2 files provided with each download of XCSEO Advanced or Pro, the files are called
modules/PHPSS_XCSEO/local.config.php and
modules/PHPSS_XCSEO/extend.xcseo.php.
When extending XCSEO for the above described scenario, your files would look like the examples provided below.
Once XCSEO has been extended properly, new sections should appear in the XCSEO Administration for each new method you've added.
modules/PHPSS_XCSEO/local.config.php:
Code:
<?php
if( !defined('XCART_START') ){
$sql_tbl['qcategories'] = 'xcart_qcategories';
$sql_tbl['questions'] = 'xcart_questions';
}
?>
modules/PHPSS_XCSEO/extend.xcseo.php:
Code:
<?php
class xcseo_filter_ext extends xcseo_filter{
function xcseo_filter_ext() {
global $sql_tbl;
parent::xcseo_filter();
$this->_types['qc'] = array(
'callback' => 'qcategory',
'file' => 'home.php',
'admin_file' => 'qcategory_modify.php',
'param' => 'qcat',
'table' => $sql_tbl['qcategories'],
'title' => 'category',
'content' => 'description',
'uniqueid' => 'catid',
);
$this->_types['q'] = array(
'callback' => 'question',
'file' => 'question.php',
'admin_file' => 'question.php',
'param' => 'qid',
'table' => $sql_tbl['questions'],
'title' => 'question',
'content' => 'answer',
);
}
function _qcategory_filename($params) {
return $this->_generic_filename('qc', $params);
}
function _question_filename($params) {
return $this->_generic_filename('q', $params);
}
function _qcategory_callback($found, $uri_only = false, $title = false) {
return $this->_generic_callback($found, 'qcat', 'qcategory', $uri_only, $title);
}
function _question_callback($found, $uri_only = false, $title = false) {
return $this->_generic_callback($found, 'qid', 'question', $uri_only, $title);
}
}
?>
Additionally, the following modification needs to be made to the Admin template file that is used for adding/modifying the new method you've added (for example, skin1/main/product_details.tpl which is used when a Product is added/modified). This modification will include the fields that XCSEO displays for modifying your URL-related entry, when you add/modify your Question, Product, whatever.
Code:
{* PHP Site Solutions - XCSEO *}
{if $active_modules.PHPSS_XCSEO}
{include file="modules/PHPSS_XCSEO/xcseo_admin_include.tpl"}
{/if}
{* END PHP Site Solutions - XCSEO *}
And that's it!
Using this method, you can extend XCSEO to support most X-Cart 3rd party addons automatically.
This method is geared specifically around how X-Cart normally manages Products, Categories, Manufacturers, Static Pages, etc, so anything that you want to extend XCSEO for, needs to be properly integrated with X-Cart, functioning as X-Cart normally would.
In other words, a 3rd party module that exists *separately* from X-Cart, would not function properly with XCSEO.
If you are trying to extend XCSEO, feel free to contact me with questions, I'll help you however I can!
Cheers