Checking approach before building (another) 2 forms!

Mizpah 25 Sep, 2009
Heya Bob/Max et all,

Having now built my form to submit car details to the database, check all of the subscription details,and the chronoviews needed to view them, my thoughts turn to managing existing data. I just want to check my methodology before driving myself and others insane 😛

I am looking for a logged in user to click an 'edit my adverts' button and be presented with an inital view where all data entries by there id/login, with a status of 'forsale' (specific column) are present. I would like an optional control on this page to include vehicles where the status is 'sold' if the status was changed to sold within (example) the last 7 days.

I am guessing that I cant use the profile page plugin, as I cant add the logged in ID to the joomla side menu dynamically ? I ideally would like to load somthing like:

header
control whats displayed
/header

body
car1 - field1 , field2, field3, fielda, fieldb fieldc - change button - edit button
car2 - field1 , field2, field3, fielda, fieldb fieldc - change button - edit button
car5 - field1 , field2, field3, fielda, fieldb fieldc - change button - edit button
/body


Where car3 and car4 are sold (not for sale), field1,2,3 are read only. Ideally fields a,b abd c will be editable on the page (thus the change button for each line).

However if in the header someone asked to also display 'sold' from the last 7 days 4 and 5 would appear.

The edit buttons will load a detailed edit page for that vehicle with many more fields capable of being modified, and an option for the user to archive the record.

So should I be using a form and the user profile plugin, or a chrono connectivity view with edit options enabled ?

I am sure I will get there with this one - it seems easier than the things completed already, but I want to make sure I structure it correctly!

Cheers,

/Miz

PS: I guess I might be getting into the territory of ajaxing this, but I probably ought to get it workinging without first!
GreyHead 25 Sep, 2009
Hi Mizpah,

As a basic rule (sometimes broken). If you want to display one record use ChronoForms, if you want to display many records use Chronoconnectivity.

NB You could use the Profile Page Plugin I think, if there is no ID in the URL then the plugin wil use the current user id.

I would use ChronoConnectivity, either with the edit-record enabled or, my preference is to build a url to link to a chronoform.

Bob
Mizpah 25 Sep, 2009
thanks Grey,

I have the basics of the second form working I believe;


<?php
//Get the currently logged in Joomla User, set to $userid
$user =& JFactory::getUser();
$userid = $user->get('id');

//Set the value of car_id to a $var in the url used to load this page
$car_id = JRequest::getString('car_id', '', 'get');

//Select anything where the car_id = and url AND the user_id is the logged in user
 
$query = "SELECT * FROM `jos_chronoforms_cars` WHERE `cf_id`= "." ".$car_id." AND `cf_user_id` = "." ".$userid." "; 
$result = mysql_query($query); 
$row = mysql_fetch_array($result);
$reg = $row[vrm];
$desc = $row[description];
$cost = $row[cost];
$status = $row[status];
?>

<pre>
<!-- debug stuff -->
<?php print_r($row); ?>
</pre>

<div>
<!-- Example read only element -->

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Registration</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="vrm" tabindex="1" name="vrm" type="text" value="<?php echo $reg; ?>" />
</div>

<div class="cfclear"> </div>
</div>


<!-- All the below should be editable -->

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" style="width: 150px;">Description</label>
    <textarea class="cf_inputbox required" rows="5" id="description" tabindex="2" title="" cols="30" name="description" value="<?php echo $desc; ?>" ></textarea>
</div>

<div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Cost</label>
    <input class="cf_inputbox validate-number" maxlength="150" size="30" title="" id="cost" tabindex="5" name="cost" type="text" value="<?php echo $cost;?>" />
</div>
  
<div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Status</label>
    <input class="cf_inputbox validate-number" maxlength="150" size="30" title="" id="cost" tabindex="5" name="status" type="text">
</textarea>
</div>
  
<div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit" name="submit" id="submit" tabindex="" type="submit" />
</div>

</div>	


That should give the second form I am after - and of course I can build the url to link to it within the chronoconnectivity output of the first form (there are typos in the the above, I need better error checking - but it shows the principle! It turns out that its just as easy to ignore the profile plugin for this purpose!

Now for the second part - do we have any examples of the header - or for tnother module position creating the where statement to control chronoconnectivity ?
GMiranda 11 Oct, 2009
Hi Bob,

Could you give a simple example of building an url to link to a chronoform?

You said: "I would use ChronoConnectivity, either with the edit-record enabled or, my preference is to build a url to link to a chronoform".

Thanks, Gonzalo
GreyHead 11 Oct, 2009
Hi Gonzalo,

I happen to be working on one right now. Here's the link

http://example.com/index.php?option=com_chronocontact&chronoformname=form_name&task=edit&cf_id=1

and the code in the Connection Body is

<a href='index.php?option=com_chronocontact&chronoformname=band_db_t1&task=edit&cf_id={cf_id}'>[Edit Data]</a>

Bob
GMiranda 13 Oct, 2009
Hi Bob,

Thanks for your answer.

I'v tried your code, but it doesn't work to me. A new blank form comes out, not the record I clicked on.

I have tried a different url and it works well.

Your code calls "com_chronocontact&chronoformname".
The code I applied calls "com_chronoconnectivity&connectionname". Also, instead of "edit" I put "editrecord".

So the code that works is:
<a href='index.php?option=com_chronoconnectivity&connectionname=Name_of_de_form&task=editrecord&cids={id}'>{name_of_de_field}</a> [in my table the ID field is id and not cf_id].

What do you think about this?
GreyHead 13 Oct, 2009
Hi Gonzalo,

If it works that's good.

Bob
GMiranda 13 Oct, 2009
Hi Bob,

I must correct my last post (in the case somebody wants to use the same code):
What the url calls is not the name of the Form but that of the Connectivity (cc) itself.
Actually, I'v got it from the url created by the cc when I apply the tag {edit_record}. It calls the very same cc where the code is.

So this is the correct code:
<a href='index.php?option=com_chronoconnectivity&connectionname=Name_of_de_Connectivity&task=editrecord&cids={id}'>{name_of_de_field}</a> [in my table the ID field is id and not cf_id].
This topic is locked and no more replies can be posted.