I'm using joomla and sobi2, I don't like the layout and want to create a way for the site visitor to choose a category from the home page which should look like this. http://www.bidmyneeds.com/index.php?option=com_sobi2&Itemid=28

Then I want them taken to this page. http://www.bidmyneeds.com/index.php?option=com_sobi2&sobi2Task=search&Itemid=28

Where the select catagory would be already populated. I've figured out that a cookie sobi2SearchCookie[cid] when set to 10 is "deck and porches" and if modify the cookie to a different number it changes the selection. But only after the first search is completed.

Name sobi2SearchCookie[cid]
Value 10
Host .www.bidmyneeds.com
Path /
Secure No
Expires At End Of Session

But I'm having problem creating the java script to create a hyperlink, that sets sob2Searchcookie[cid] when it is clicked. (really I don't have a clue)

Also, this may be important, there is a cookie created after the geo search which is
Name 004b3328e3e75e02c13a06e35471f97d
Value e0c8d90a6cda9baaecf61a62a2b49497
Host bidmyneeds.com
Path /
Secure No
Expires At End Of Session

I'd like to add that I've found this code, I'm by no means good with java, but is this code clearing the cookie, the first time it is loaded?

/* searching in categories */
$cid = (int) sobi2Config::request($_REQUEST, "sobiCid", 0);
setcookie("sobi2SearchCookie[cid]", $cid, 0, "/", $cookieDomain);

if(!empty($sIDs) || !$searching) {
if($cid && $cid !=0) {
if(!is_array($sIDs) || empty($sIDs)) {
$itids = null;
}
else {
$ids = implode(" , ", $sIDs);
$itids = "AND itemid IN ({$ids})";
}
$cids = array();
$config->getChildCats($cid, $cids);
$cids = implode(" , ", $cids);
$query = "SELECT itemid FROM #__sobi2_cat_items_relations WHERE catid IN({$cids}) {$itids} ;";
$database->setQuery($query);
$sIDs = $database->loadResultArray();
if( empty( $sIDs ) ) {
$sIDs = array( 0 );
}
}
}
/* getting plugins modifications */
$pluginsOutput = null;
if(!empty($config->S2_plugins)) {
foreach ($config->S2_plugins as $plugin) {
if(method_exists($plugin,"onAjaxSearchResult")) {
$plugin->onAjaxSearchResult($sIDs, $dataForFields, $pluginsOutput);
}
}
}

$total = count($sIDs);

if($total) {
$whereId = implode(" , ", $sIDs);
$now = $config->getTimeAndDate();

$query = "SELECT COUNT(itemid) FROM `#__sobi2_item` " .
"WHERE ( itemid IN ({$whereId}) AND `published` = 1 AND (`publish_down` > '{$now}' OR `publish_down` = '{$config->nullDate}' ) ) ";
$database->setQuery($query);
if($database->loadResult()) {
$total = $database->loadResult();
}
else {
$total = 0;
}
}

$items = array();
$page = 0;
$pages = 0;
if($total) {
/*
* now we have all id's from items contains search strings
*/

Is this even a Javascript question given that what you have posted seems like PHP? If you want to manipulate cookies using Javascript, read this. If this really is a PHP question, allow me to move it to the PHP forum.

I believe it has to be a java script question, because I want to create links that set a cookie within php, and from my quick reading on php you have to set cookies before any output?

And the easy way to set cookies is with java inside php.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.