Advertisement:

Author Topic: how to pass category in item-post.php  (Read 978 times)

mandi007

  • Full Member
  • ***
  • Posts: 204
how to pass category in item-post.php
« on: February 03, 2018, 09:37:43 am »
i need to input the category in the item post url like we input in search page like domain.com/search/pattern,nokia/category,mobile-phones"

likewise

domain.com/item/new/category,mobile-phones

how to input category in the post url so the category is preselected

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: how to pass category in item-post.php
« Reply #1 on: February 03, 2018, 01:38:22 pm »
***CORRECTED***

Hi,

Theme header.php

Replace:

Code: [Select]
            <?php if( osc_users_enabled() || ( !osc_users_enabled() && !osc_reg_user_post() )) { ?>


with:

Code: [Select]
        <?php if( osc_users_enabled() || ( !osc_users_enabled() && !osc_reg_user_post() )) {
            
$current_category osc_search_category_id();
            if (
count($current_category) == 1) {
                
$hasSubcategories Category::newInstance()->findSubcategoriesEnabled($current_category[0]);
                if (empty(
$hasSubcategories)) {
                    
$current_category Category::newInstance()->findByPrimaryKey($current_category[0]);
                    
View::newInstance()->_exportVariableToView('category'$current_category);
                } 
            } 
?>


Regards
« Last Edit: February 03, 2018, 03:46:07 pm by teseo »

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to pass category in item-post.php
« Reply #2 on: February 03, 2018, 02:04:49 pm »
hi teseo happy to see you , i thought you left this forum because you are in spot light in all threads now now i cant find you like old days ;D

i need to input a category in item post url, for example a category named mobile-phone by name or id so the loaded page comes with a pre selected category. so user no need to select a category.

i want to display this link in the category page so the user click this link it should take me to item-post page with the category pre selected that we give in the url.

explained again in different view so you can better understand my need...

the modifcation you given will it help me to achieve this


« Last Edit: February 03, 2018, 02:06:28 pm by mandi007 »

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to pass category in item-post.php
« Reply #3 on: February 03, 2018, 02:12:39 pm »
Oh my god .......... it is working teseo!!!!

you are the God Father of this clan

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to pass category in item-post.php
« Reply #4 on: February 03, 2018, 02:24:16 pm »
teseo a small problem,

if from main category a user is clicking the item post url parent category is pre selected but the sub category drop down is not showing and if i submit the form it says category invaild because of sub not selected, any solution .....

but from sub category page eveything works fine but only parent category is problem

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to pass category in item-post.php
« Reply #5 on: February 03, 2018, 02:26:12 pm »
how to restrict like if(!parent_category){your code} or else normal item post link

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: how to pass category in item-post.php
« Reply #6 on: February 03, 2018, 03:46:57 pm »
See my corrected post above.

Regards

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to pass category in item-post.php
« Reply #7 on: February 03, 2018, 08:12:12 pm »
Thank you working awesome

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: how to pass category in item-post.php
« Reply #8 on: February 04, 2018, 01:44:43 pm »
You're welcome. :) Please add [SOLVED] to the title of this thread.

Regards