10 years ago
4
Topic

Hi all,

i'm trying to build a query in select dynamic field (located in the submission form) to substitute article related field (which gives me list of articles in category instead of current user articles)

So I made query:

SELECT #__content.catid, #__content.id AS value, #__content.title AS text, #__users.id, #__content.created_by FROM #__content INNER JOIN #__users ON #__users.id=#__content.created_by WHERE #__content.catid=12 AND #__content.created_by=626

where 12 is category i need and, actually, 626=logged in user. But I must use an variable or something else to exchange "626" by real ID of logged in user.

Solution:

#__content.created_by=#__users.id

doesn't work as I want because I see the same list of articles from the category 12.

And another issue, to completely substitute article related field (as far as i understand) I can add simply css class "cck_form cck_form_joomla_article". Is it enpugh?

Get a VIP membership
10 years ago
0
Level 1

Hi,

Did you find any solution, I have the same problem ...

Thanks

32 Posts
G.Bob
10 years ago
0
Level 1

Hello, maybe you can use this, the information of current logged user

$user = JFactory::getUser();
$userid = $user->id

and ypur query --->> WHERE #__content.catid=12 AND #__content.created_by= $userid

UPDATE : Sorry, don't work, you can't put that in the free query construction.

32 Posts
G.Bob
10 years ago
1
Level 1

Re Terveg

have you tried with a field core 42, I put the following code in the "prepare form" box :

<code>

$user = JFactory::getUser();
$userid = $user->id;
$query ='SELECT #__content.id, #__content.title FROM #__content INNER JOIN #__users ON #__users.id = #__content.created_by WHERE #__content.catid = 12 AND #__content.created_by = ' .$userid;
$results = JCckDatabase::loadObjectList( $query );
print_r($results);
$tbx .= '<select id="yourid" name="yourname" size="1">';
$tbx .= '<option value="" selected="selected">- Choisissez une option</option>';
foreach($results as $index=>$Valeur) {
$tbx .= '<option value="'.$Valeur->id.'">'.$Valeur->title.'</option>';
};

$tbx .= '</select>';
$form = $tbx;

</code>

bye

10 years ago
0
Level 2

Hi G.Bob

I found an efficient solution with this post :

http://www.seblod.com/community/forums/fields-plug-ins/select-dynamic-with-fields-variables

Thanks for your solution, I'm going to test it.

Dom.

Get a VIP membership