Advertisement:

Author Topic: Basic category dropdown box mod  (Read 3137 times)

mon

  • Jr. Member
  • **
  • Posts: 83
Basic category dropdown box mod
« on: May 18, 2013, 05:24:49 pm »
How can I change this code so that when user selects a category, it keeps selected in the dropdown box after submit button?

Code: [Select]
<?php  if ( osc_count_categories() ) { ?>
            <?php osc_categories_select('sCategory'null__('Selecciona categoría''twitter')); ?>
        <?php  ?>

I dont want to use another code, I just want to know where to change this one so it keeps category selection.
The reason why I dont want to replace this code with another category dropdown box cod is because if I do so, the style I defined in Category.form.class.php will no longer be called.
« Last Edit: May 21, 2013, 03:12:31 pm by mon »

pandeg

  • Newbie
  • *
  • Posts: 6
Re: How to change the following category code?
« Reply #1 on: May 18, 2013, 08:46:32 pm »
same problem with me,  anybody help?

mon

  • Jr. Member
  • **
  • Posts: 83
Re: How to change the following category code?
« Reply #2 on: May 21, 2013, 03:10:24 pm »
Why is it so difficult to find such a basic mod for this?
If in inc.search.php there is a dropdown category box that can be styled in Category.form.class.php, why isnt the SAME dropdown box inside sidebar in search.php ?
Why has the creator done this? I find it so anoying to select diselect category checkboxes in sidebar after that EASY inc.search.php dropdown box.
Cant understand the reason for this. Can someone help making a basic category dropdown box equal to the one in inc.search.php that remembers the users selection?
This is the code need to modify that keeps the style but obviously not the selection:
Code: [Select]
        <?php  if ( osc_count_categories() ) { ?>
            <?php osc_categories_select('sCategory'null__('Select a category''modern')); ?>
        <?php  ?>

rangdak

  • Newbie
  • *
  • Posts: 1
Re: Basic category dropdown box mod
« Reply #3 on: August 27, 2013, 08:28:39 pm »
Hi! This worked for me:

In Category.form.class.php

Line 37
echo '<option value="' . $c['pk_i_id'] . '"' . ( ($category['pk_i_id'] == $c['pk_i_id']) ? 'selected="selected"' : '' ) . '>' . $c['s_name'] . '</option>';

Change it to:
echo '<option value="' . $c['pk_i_id'] . '"' . ( ($c['pk_i_id']==$_GET["sCategory"]) ? 'selected="selected"' : '' ) . '>' . $c['s_name'] . '</option>';

AVBestDeals

  • Full Member
  • ***
  • Posts: 121
Re: Basic category dropdown box mod
« Reply #4 on: August 27, 2013, 08:52:20 pm »
Hi

Thanks for the tip:
In case other user do not know where the file is located = oc-includes / osclass / frm / Category.form.class.php


AVBestDeals


Hi! This worked for me:

In Category.form.class.php

Line 37
echo '<option value="' . $c['pk_i_id'] . '"' . ( ($category['pk_i_id'] == $c['pk_i_id']) ? 'selected="selected"' : '' ) . '>' . $c['s_name'] . '</option>';

Change it to:
echo '<option value="' . $c['pk_i_id'] . '"' . ( ($c['pk_i_id']==$_GET["sCategory"]) ? 'selected="selected"' : '' ) . '>' . $c['s_name'] . '</option>';

ragugo

  • Newbie
  • *
  • Posts: 10
Re: Basic category dropdown box mod
« Reply #5 on: September 26, 2013, 07:50:26 pm »
It work but only with Category, what about Subcategory?

GoodLooker

  • Newbie
  • *
  • Posts: 4
Re: Basic category dropdown box mod
« Reply #6 on: October 11, 2013, 11:49:47 pm »
Hi, here's a solution, file to edit: /oc-includes/osclass/frm/Category.form.class.php.

1) replace:
Code: [Select]
echo '<option value="' . $c['pk_i_id'] . '"' . ( ($category['pk_i_id'] == $c['pk_i_id']) ? 'selected="selected"' : '' ) . '>' . $c['s_name'] . '</option>';
1) with:
Code: [Select]
echo '<option value="' . $c['pk_i_id'] . '"' . ( (Params::getParam('sCategory') == $c['pk_i_id']) ? 'selected="selected"' : '' ) . '>' . $c['s_name'] . '</option>';
2) replace:
Code: [Select]
echo '<option value="' . $c['pk_i_id'] . '"' . ( ($category['pk_i_id'] == $c['pk_i_id']) ? 'selected="selected"' : '' ) . '>' . $deep_string.$c['s_name'] . '</option>';

2) with:
Code: [Select]
echo '<option value="' . $c['pk_i_id'] . '"' . ( (Params::getParam('sCategory') == $c['pk_i_id']) ? 'selected="selected"' : '' ) . '>' . $deep_string.$c['s_name'] . '</option>';
« Last Edit: October 12, 2013, 12:00:59 am by GoodLooker »