klox7 VIP
Total posts: 914
14 Oct 2014 12:25

Hi,

I want to ask
if user can somehow submit his article
without having to select category
and if category can be auto selected
based on it's parent category?

SETUP:
section1 - type1
section2 - type2

section3
-category3.1 (type3)
--subcategory3.1.1
-category3.2 (type3)
--subcategory3.2.1

In type1 comments parameters I'm forcing category3.1 and in type2 comments parameters I'm forcing category.3.2. I'm not allowing submission to section root (section3).

For type3 I'm forcing 2 categories, that's subcategory3.1.1 and subcategory3.2.1 and I don't allow user to choose category.

I'm asking if it's possible for Cobalt to know if I add comment for category3.1 that it will save this comment in subcategory3.1.1? And if I add comment for category3.2 that it will save this comment in subcategory3.2.1?

Regards

Last Modified: 21 Oct 2014


Sergey
Total posts: 13,748
15 Oct 2014 02:48

klox7 I'm asking if it's possible for Cobalt to know if I add comment for category3.1 that it will save this comment in subcategory3.1.1?

Why do not you simply force it 3.1.1 or 3.2.1? But of course you can dothat in custom form template.


klox7 VIP
Total posts: 914
15 Oct 2014 06:10

Sergey Why do not you simply force it 3.1.1 or 3.2.1?

This will be possible in parameters if I had separate types, type3 and type4, right?

Sergey But of course you can dothat in custom form template.

Do I copy default_form_default.php or one of the category template? Where can I found out how to force to category?


Sergey
Total posts: 13,748
15 Oct 2014 12:11

klox7 This will be possible in parameters if I had separate types, type3 and type4, right?

Why? Id you can fose already to category 3.1 why cannot you force to 3.1.1? Just force to diferent category.

klox7 Do I copy default_form_default.php or one of the category template? Where can I found out how to force to category?

make copy in template manager. Then edit and find lines where category field is displaied. Delete it and insert hidden field

<input type="text" name="jform[category][]" value="<?php echo $cval; ?>">

Where $cval is an ID of the category you want to post it. You may define this by looking at URL value. Or type_id.


klox7 VIP
Total posts: 914
15 Oct 2014 12:22

Sergey Why? Id you can fose already to category 3.1 why cannot you force to 3.1.1? Just force to diferent category.

Force to category in comments parameters for one type has one input. You can insert multiple categories id's by separate them with comma. But if you disable select category option in form view then this is irrelevant. System will not know to which category to post.


klox7 VIP
Total posts: 914
20 Oct 2014 14:30

How could I use something like this in the form and that will acctually work?

<?php 
$parent = ItemsStore::getRecord($item->parent_id);
if($parent->categories = 150): ?>
    <?php echo '<input type="text" name="jform[category][]" value="162">';?>
<?php endif; ?>

The idea is when users clicks add comment button and if parent item is in category 150 I want to force post to category 162.


Konstantin
Total posts: 1,113
21 Oct 2014 05:21

How I understand you want prevet category select only if cat_id = 150, in otherwise user can select category, isn't it?

So I think you must use something like this:

<?php 
$parent = ItemsStore::getRecord($item->parent_id);
if($parent->category_id == 150): ?>
    <input type="hidden" name="jform[category][]" value="162">
<?php else: ?>
    <?php echo $this->loadTemplate('category_'.$params->get('tmpl_params.tmpl_category', 'default')); ?>
<?php endif; ?>

instead this line:

    <?php echo $this->loadTemplate('category_'.$params->get('tmpl_params.tmpl_category', 'default')); ?>

on line 196 in default_form_default.php

Powered by Cobalt