131 Posts
layonill
5 years ago
Topic

I am using the dynamic selection into an article form, it is suppose to give me all categories that are created, but it shows nothing, how do I fix this?

Get a VIP membership
4229 Posts
Kadministrator
5 years ago
5
Level 1

It is impossible to help you based on your description as it only states it does nor work for you, for the start copy the query you created.

131 Posts
layonill
5 years ago
4
Level 2

the query  is in construction mode, in that case I just have to put the name of the table, #__categories, and the WHERE created_by = $user->id, but it does not show me the fields, why it does not give me the info?

4229 Posts
Kadministrator
5 years ago
3
Level 3

Your query is not correct, you need to define text and value properties https://www.seblod.com/resources/extensions/archives/seblod-2-x-select-dynamic-field

131 Posts
layonill
5 years ago
2
Level 4

I did that, the text=title and value =id, the page gives me an error

4229 Posts
Kadministrator
5 years ago
1
Level 5
SELECT title AS text, id AS value from #__categories 

should work. Otherwise there is something broken on your system.

131 Posts
layonill
5 years ago
0
Level 6

where do I add the created_by = $user->id?

45 Posts
Jan
5 years ago
6
Level 1

See

https://www.seblod.com/community/forums/fields-plug-ins/select-dynamic-problem#post60660

131 Posts
layonill
5 years ago
5
Level 2

but you write that in phpmyadmin or in the field construction?

45 Posts
Jan
5 years ago
4
Level 3

In neither of these. I have added

// Set
$field->value = $value;

on line 533 and 534 of select_dynamic.php in \plugins\cck_field\select_dynamic. This is for version 3.17.1 (Seblod 3.17.1) If you use another version look in select_dynamic.php and find function onCCK_FieldPrepareSearch. Add the lines just before //Return like this:

// onCCK_FieldPrepareSearch
public function onCCK_FieldPrepareSearch( &$field, $value = '', &$config = array(), $inherit = array(), $return = false )
{
if ( self::$type != $field->type ) {
return;
}

// Init
if ( $field->bool3 ) {
$divider = $field->match_value ? $field->match_value : $field->divider;
$field->match_value = $divider;
if ( is_array( $value ) ) {
$value = implode( $divider, $value );
}

$field->divider = $divider;
} else {
$field->match_value = $field->match_value ? $field->match_value : ',';
}
self::onCCK_FieldPrepareForm( $field, $value, $config, $inherit, $return );

// Set
$field->value = $value;

// Return
if ( $return === true ) {
return $field;
}
}

131 Posts
layonill
5 years ago
3
Level 4

how do I ad the created by user?, is the only thing I need to complete this so i gives me the values based on the current user logged, the query right now is like this "SELECT title AS text, id AS value from #__categories WHERE parent_id=8" I just need to know how do I make it to show me the info of the current user, it's almost complete

45 Posts
Jan
5 years ago
2
Level 5

I don't know. The table #__categories has a column created_user_id. You can retrieve those numbers. I don't know how to get the live user out of these.

4229 Posts
Kadministrator
5 years ago
1
Level 6

I tested and there is no bug, everything works correctly - your problem is there is no "created_by" column in categories table, correct query which works is

SELECT title as text, id as value FROM #__categories WHERE created_user_id = $user->id
131 Posts
layonill
5 years ago
0
Level 7

solved, thanks a lot

Get a Book for SEBLOD