Forums

Checkform

DaveHall 26 Nov, 2008
Within this Javascript function the front_edit_template is parsed to replace <?php and ?> with [startphp] and [endphp] respectively.

Unfortunately only the first occurrence is currently replaced. I changed the line doing the replace to:

Template.innerHTML = $('front_edit_template').value.replace(/<\?php/g, "[startphp]").replace(/\?>/g, "[endphp]");
Max_admin 26 Nov, 2008
Hi Dave, Thanks for the fix, will check it and include it in the next release!

Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
gporterfield 27 Nov, 2008
Max:

This sounds like the same problem that I have been having. Can you tell me which file needs to be edited and the specific line so I can try the same patch. (My initial searches did not find a line that I was confident in replacing.)

Thanks,
George
Max_admin 27 Nov, 2008
Hi, its in admin.chronoconnectivity.html.php, find some line with:

Template.innerHTML = $('front_edit_template').value.replace


Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
gporterfield 28 Nov, 2008
This patch helped some. At least the second and third occurence of PHP code in the template is being converted from the normal php tags to the [startphp] and [endphp] tags. But it still is getting tripped up on some of the other "greater than" characters in between.

This code is in the record template for the front end.
<?php 
    echo "<table><tr valign=top><td colspan=3><select name="Room">";
    foreach($locations as $location){
        echo "<option value=".$location->room.">".$location->room."</option>";
    } 
    echo "</select></td></tr></table>";
?>

<table>
<tr><td colspan="3"><br></td></tr>
<tr valign="top" bgcolor="#FFFFBF"><td colspan=3><b>Description</b></td></tr>

<?php echo "<tr><td colspan=3>";
      echo $editor->display( 'Description',  '' , '100%', '200', '75', '20', false ) ;
      echo "</td></tr>";
?>

According to the Autogenerated tab, this is converted to this code:
>[startphp] echo "
<TABLE>
<TBODY>
<TR vAlign=top>
<TD colSpan=3><SELECT ccnamex='"Room"'>"; foreach($locations as $location){ echo "<OPTION value="" selected ccvaluex=".$location->room." ccphpx="[startphp] if("{"Room"}" == ".$location->room.")echo "selected='selected'";[endphp]ccphpx">".$location->room."</OPTION>"; } echo "</SELECT></TD></TR></TBODY></TABLE>"; [endphp] 
<TABLE>
<TBODY>
<TR>
<TD colSpan=3><BR></TD></TR>
<TR vAlign=top bgColor=#ffffbf>
<TD colSpan=3><B>Description</B></TD></TR>[startphp] echo "
<TR>
<TD colSpan=3>"; echo $editor->display( 'Description', '' , '100%', '200', '75', '20', false ) ; echo "</TD></TR>"; [endphp] 
The parsing seems to get confused some by the other greater than signs in the select control. Part of the problem appears to be the insertion of the test for the selected value. This results in the following error message when trying to edit a record in the table.

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/ctbc/public_html/components/com_chronoconnectivity/chronoconnectivity.html.php(283) : eval()'d code on line



The autogenerated code for the third segment of PHP code looks OK, but the displayed page shows the editor with no text content from the database.

George
Max_admin 28 Nov, 2008
Hi gporterfield,

which browser do you use while doing this ? try firefox v3.0 if possible and let me know!

Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
gporterfield 29 Nov, 2008
I am on the road right now, so this happened when using IE6. When I get home in a few days, I will check it with FF3 which is my usual and preferred browser.

Thanks,
George
Max_admin 30 Nov, 2008
Ok, let me know!

Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
gporterfield 02 Dec, 2008
Max:

I tried the same code using FireFox 3.04 and got the same results as I did with IE6. I did make sure that the auto-generated code was updated.

George
Max_admin 02 Dec, 2008
Ok, I will test this and get back to you!

regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
DaveHall 03 Dec, 2008
Hi George/Max,

Out of interest, where is $locations coming from in your code?

My form always references $row->something to get at a column in the connected table.

It looks to me that you have nested [startphp] [endphp], this is not going to work!

I think we need to better understand how <select> in chronoconnectivity is meant to work. I think the intent, although maybe it's not there yet, is to have a column with the options, say locations, where the column contains a comma separated option list and another column, say location, which will contain the user selected value from the form.

With this set up chronoconnectivity can/could handle all the hard work for you and you don't need any php code!

Thoughts?

Cheers,
Dave
GreyHead 03 Dec, 2008
Hi Dave,

I think I can answer one piece, George has
foreach($locations as $location)
instead of the more common
foreach($rows as $row)
Either is OK.

Bob
gporterfield 03 Dec, 2008
Max and Bob:

The data for $locations is coming from another table. The following code is at the top of my template entry.
<?php
    JHTML::_('behavior.calendar');
    $editor =& JFactory::getEditor();
    $database->setQuery( 'SELECT room FROM #__ctrooms ORDER BY room;' );
    $locations = $database->loadObjectList();
?>

This data is maintained in another table since it can change as often as monthly. I have a working ChronoConnectivity connection setup to maintain that table.

BTW, would it be possible to add a backup and restore function to CC much like in ChronoForms?

George
Max_admin 04 Dec, 2008
Hi George,

I think Dave mixed this with the core code, I understand that this your code and I will look into this but didn't have time yet!

@Dave, ChronoConnectivity will just process the code given by the user, at this example we query the user's table!😉

Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
gporterfield 06 Dec, 2008
Max:

The code in one of my previous entries on this thread is my user code as you stated. It seems that it is not being interpreted or parsed correctly, thereby causing the extra "[startphp]" entries in the auto-generated code.

I traced this with Firebug and I think the problem is caused by the code around lines 237-239 of admin.chronoconnectivity.html.php. This code is inserting a "[startphp]" tag without checking first if it is in the middle of a php code segment or not. I'm not sure if it is possible to determine this and make the insertion of the start tag optional. If your code can not check for this, then we may have to figure out what strict structure to use in the user code to prevent this situation.

BTW, similar code works OK for the back end Admin. Config.

George
Max_admin 07 Dec, 2008
Hi George,

Thanks for posting the clue for this, I will see if its possible to fix this issue and get back once I have any news! you may now try to add php close tags before this to fix the problem.

Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
gporterfield 07 Dec, 2008
Max:

I tried inserting my own end php tags, but the string that is being inserted (to show the selected entry) has some php code before it inserts the start php tag. This text in between then confuses things even more.

George
gporterfield 09 Dec, 2008
Max:

I managed to come up with a "work around." It take an entirely different approach for now, but I would eventually like to go back to the original, more straight forward coding.

First, at the very beginning of my front-end template, I read the second database table that is used to populate the select object.
<?php
    $database->setQuery( 'SELECT room FROM #__ctrooms ORDER BY room;' );
    $locations = $database->loadObjectList();
?>

In the middle of my form, I include an empty select object.
<table><tr valign=top><td colspan=3><select name=Room>
</select></td></tr></table>

Then at the bottom of my template, I use some javascript and php to populate the select object and determine the correct entry to set as "selected."
<script type="text/javascript">
var roomSelect=document.forms[1].Room
<?php
    foreach($locations as $location){
        echo "roomSelect.options[roomSelect.options.length]=new Option('";
        echo $location->room;
        echo "', '";
        echo $location->room;
        echo "', false, ";
        if ("{Room}" == "$location->room") {echo "true);";} else {echo "false);";};
    }
?>
</script>


George
Max_admin 09 Dec, 2008
Glad you found a workaround, of course I want to reach with this to the maximum flexibility, will see what can be done!

Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.