Zen Cart Logo
Forums / Customization from the Admin / Stripping the Admin Category Page

Stripping the Admin Category Page

Views: 810

Results 1 to 2 of 2
9 Feb 2017, 7:34 PM
#1
tmpinsnty avatar

tmpinsnty

New Zenner

Join Date:
Jun 2016
Location:
Minneapolis, MN
Posts:
37
Plugin Contributions:
0

Stripping the Admin Category Page

I have PHP 5.6.0 and MySql 5.5.54.
I believe we have COWOA installed on this store and the Categories Center Box Mod by Numinex

But we have taken our main site and made clones of it for our customers as we are wholesalers and want to offer our clients a way to have an online catalog of our products.
So while this is 151 its been HEAVILY modified to have this functionality. Unfortunately I did not do the modifications, the guy who did them didn't document, and I have 7 months experience with Web Design. (I've been working for this company for 7 months.)

One of the functionalities my boss wants for these sites is to allow our customers to select which categories they want to show on their site. So what I want to do is strip most of the functionality of the admin categories page to just allow them to turn off/on the categories. Nothing Else. I don't need it to go to the other page and warn them that is will turn off all the products also.

So my thought was to change this in the categories_product_listing.php module:

<?php
      if ($categories->fields['categories_status'] == '1') {
        echo  zen_draw_form('setflag_categories', FILENAME_CATEGORIES, 'action=setflag&cID=' . $categories>fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?> 
        <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_green_on.gif" title="<?php echo IMAGE_ICON_STATUS_ON; ?>" />
        <input type="hidden" name="flag" value="0" />
        </form>
<?php			
	  	}else {
         echo  zen_draw_form('setflag_categories', FILENAME_CATEGORIES, 'action=setflag&cID=' . $categories>fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?> 
        <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_red_on.gif" title="<?php echo IMAGE_ICON_STATUS_OFF; ?>" />
        <input type="hidden" name="flag" value="0" />
        </form>
      }

Which I believe will mimic what happens when a single product is turned on/off. That is this code.

<?php
      if ($products->fields['products_status'] == '1') {
        echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
        <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_green_on.gif" title="<?php echo IMAGE_ICON_STATUS_ON; ?>" />
        <input type="hidden" name="flag" value="0" />
        </form>
<?php
      } else {
        echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
        <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_red_on.gif" title="<?php echo IMAGE_ICON_STATUS_OFF; ?>"/>
        <input type="hidden" name="flag" value="1" />
        </form>

Here is the original code from categories_products_listing:

?php
      if ($categories->fields['categories_status'] == '1') {
        echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=0&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . '</a>';
      } else {
        echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=1&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>';
      }
      if (zen_get_products_to_categories($categories->fields['categories_id'], true, 'products_active') == 'true') {
        echo '  ' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED);
      }
?>

So can y'all look it over and see if what I did wrong because right now the categories.php is only loading the legend.
:frusty:
Oh yeah I have looked at my Logs and nothing has been added.
Thank you so much for all the help! I've scoured this site many a times looking for answers and plugins.

This is our main site:

Wholesale Store

This is one of our clone sites:
Cloned Store (my test one)

I'm sure it's something easy stupid that I missed since I've been working on this since 6:30 am

9 Feb 2017, 7:58 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stripping the Admin Category Page

Oye. So a ZC 1.5.1 site (5+ years old now) running on PHP 5.6 (was hardly a twinkle in the PHP writers eyes) to have the admin/categories.php file modified to try to disable categories on the store front without asking about the condition of the product.

Takes more than modifying the action portion of the link. Need to look at what that action does/needs.

Setflag as found by searching for 'setflag' (with single quote) expects the pID to be on the uri in order to change the status and as is, only the product status is set/designed to be modified.

This can be determined by looking at the provided/revised line. Basically what it is saying is: load the categories page, assign the action to be setflag, and the cID to the category selected/clicked on and change its condition (true to false or false to true). So, when the page is loaded, the action is inspected and based on the provided action, the applicable code is executed.

The default action for status change of the category is 'setflag_categories'. If you wish that operation to change then need to locate where the code is to "respond" when the action is set to that, or need to create a separate action command to obtain the result(s) desired which could be similar to setflag but does all of the action that you are wanting to be done when "bypassing" the current "warning". Whether that is to go ahead and disable the product, enable all of the product or leave as is...

Shame that now for them to either enable all or disable all that they would have to select each product individually or write a sql query themselves to do so...