Forums

dynamic list in custom element wizard

padideh 11 Apr, 2011
Hi
I'm new with Chrono and I wonder how I can write new custom element with php code, just like codes we can write in Chronoconnectivity.
I mean something like this:

<select>
<?php
for ($i=0;$i<10;<$i++){
  echo "<option value='".$i."'>".$i."</option>\r\n";
}
?>
</select>

and I really appreciate if someone helps me in order to make user list from joomla
thanks indeed
GreyHead 11 Apr, 2011
Hi padideh,

I'm not sure if you can put PHP in a custom element. You can add this code to the Form HTML though.

The user list answer has been posted here a couple of times recently.

Bob
padideh 11 Apr, 2011
Hi GreyHead
thank you for your answer
I'm afraid I don't know where the "form html" is however I couldn't find the topic that you mentioned.
what exactly I need is to make user list from joomla database
I think it should be simple for powerful form maker like chronoforms and I just don't know where to look for it
thank you
GreyHead 11 Apr, 2011
Hi padideh,

Here's one example I found:
<select class="cf_inputbox validate-selection" id="cf_user_id" size="1" title=""  name="cf_user_id">
  <option value="">Select</option>
<?php
$db =& JFactory::getDBO();
$query = "
  SELECT *
    FROM #__users ;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ($data as $d) {
  echo "<option value='".$d->id."'>".$d->name."</option>";
}
?>
</select>

Bob
padideh 11 Apr, 2011
thank you so much
it worked perfectly
there is one more thing and I really appreciate if you could help me
assume there are 3 persons in my website (one manager and two customers)
manager wants to upload a file for one of them.
manager can upload files and simply select user just like you said.
and I made a page with chronoconnectivity for the person who wants to see the files.
this is where sql in chronoconnectivity:

<?php
$user = JFactory::getUser();
$id = $user->get('id');
echo "where cf_user_id = '$id'";
?>

and this is body in chronoconnectivity:

<tr>
<td>
{text_1}

</td>
<td>
<?php echo "<a href='components/com_chronocontact/uploadsew/";?>
{file_3}
<?php echo "'>"?>
Download
<?php echo "</a>";
?>
</td>
</tr>

it works but my problem is that this link exhibits the directory path and if someone knows the file name, simply can use the address bar and download it, I mean files are available for everyone
it was what I've done so far.
so is there any way to make this links indirectly?
thanks
GreyHead 18 Apr, 2011
Hi padideh,

I don't know; I'd probably add a random string to the file name to make it hard to guess.

Bob
padideh 01 May, 2011
thank you so much.
This topic is locked and no more replies can be posted.