More Issues With selectedCategoryNum

5 posts by 2 authors in: Forums > CMS Builder
Last Post: March 29, 2010   (RSS)

By Perchpole - March 26, 2010

NB: I've already outlined similar problems in this thread...

$selectedCategory and Pagination conflict?

I've now encountered another issue which also has the potential to mess things up.

When using a search query which includes a space, such as...

www.mysite.com/index.php?category=3&type=diesel engine

...the returned selectedCategoryNum is always 20.

Presumably this is because of the way URL encoding replaces spaces with %20.

As selectedCategoryNum is defined by getNumberFromEndOfUrl, the system concludes that category 20 has been loaded.

Interestingly, it does this even though a category number has already been defined in the URL! The system seems to over-ride this information because %20 is the last number in the string.

I hate to keep banging on about this issue but it's proving to be a real thorn in my side. I'm trying to design dynamic pages which load/filter content based on specific criteria. Often the most important factor is the selected category as this dictates which sub-menus and supplementary page info is displayed.

If this framework isn't consistent, the whole thing falls apart - rendering it next to useless.

I really hope this issue is on the to-do list!

:0/

Perch

Re: [chris] More Issues With selectedCategoryNum

By Perchpole - March 29, 2010

Hi, Chris -

Thanks for your input. However, I'm not entirely sure this is a fix - certainly not the one I'm looking for!

As far as I can tell, your update simply defines a default categoryNum - in any eventuality.

'selectedCategoryNum' => x,

In my example, however...

www.mysite.com/index.php?category=3&type=diesel engine

...I want the category to be 3, as defined by the URL, regardless of any other factor.


If there is no category defined in the URL...

www.mysite.com/index.php?type=diesel engine

...then it can default to the setting in the page viewer...

'selectedCategoryNum' => x,

Surely that's the only way to make the category structure dynamic and consistent?

[:/]

Perchpole

Re: [Perchpole] More Issues With selectedCategoryNum

By Chris - March 29, 2010

Hi Perchpole,

Sorry, I thought this issue was more related to the other thread than it is.

Does this work?

'selectedCategoryNum' => @$_REQUEST['category'],

I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] More Issues With selectedCategoryNum

By Perchpole - March 29, 2010

Hi, Chris -

It actually works (best) like this...

$homeCategoryNum = 1;
$selectedCategoryNum = @$_REQUEST['category'];
if (!$selectedCategoryNum) { $selectedCategoryNum = $homeCategoryNum; }

Then...

'selectedCategoryNum' => $selectedCategoryNum,

Deffinitely getting somewhere!

:0)

Perch