Error Using Multiple Models in CCv5

mitey 06 Jan, 2014
I have left CCv4 out of frustration, because though it doesn't have this very issue, I have difficulty in creation and editing of records. So, hopefully, with your help, this will work out.

I am trying to create a means for users to submit article on the frontend, using CF and CC. Also, I need to add some new fields to Joomla's content. To prevent future updates from destroying the website, I decided to create a new DB table to hold all the needed extra fields.

The problem I'm having right now is that I cannot get CCv5 to fetch data from the extra table. Surprisingly though, I was able to get data from the users table on the first try.

Below is the structure of the extra table:
tbl_content_extra
[list]
  • id

  • article_id

  • category

  • approved

  • [/list]

    I have tried all possible combination of settings within the model setting, but none is working.

    In Join Conditions, I have
    <?php return array("Extra.article_id"=>"Article.id"); ?>


    I have enabled debug and this is what is returned
    Array
    (
        [0] => SELECT `Extension`.`id` AS `Extension.id`, `Extension`.`name` AS `Extension.name` FROM `o7ge4_chronoengine_extensions` AS `Extension` WHERE `Extension`.`enabled` = '1' ORDER BY `Extension`.`ordering` ASC
        [1] => SELECT `Connection`.`id` AS `Connection.id`, `Connection`.`title` AS `Connection.title`, `Connection`.`params` AS `Connection.params`, `Connection`.`extras` AS `Connection.extras`, `Connection`.`published` AS `Connection.published` FROM `o7ge4_chronoengine_connections` AS `Connection` WHERE `Connection`.`title` = 'Briefs' AND `Connection`.`published` = '1'
        [2] => SELECT COUNT(*) AS `Article.count` FROM `o7ge4_content` AS `Article` LEFT JOIN `o7ge4_content_extra` AS `Extra` ON `Extra`.`article_id` = 'Article.id' LEFT JOIN `o7ge4_users` AS `Author` ON `Article`.`created_by` = 'Author.id' WHERE `Article`.`catid` = '8' GROUP BY `Article`.`id`, `Article`.`id`
        [3] => SELECT `Article`.`id` AS `Article.id`, `Article`.`asset_id` AS `Article.asset_id`, `Article`.`title` AS `Article.title`, `Article`.`alias` AS `Article.alias`, `Article`.`introtext` AS `Article.introtext`, `Article`.`fulltext` AS `Article.fulltext`, `Article`.`state` AS `Article.state`, `Article`.`catid` AS `Article.catid`, `Article`.`created` AS `Article.created`, `Article`.`created_by` AS `Article.created_by`, `Article`.`created_by_alias` AS `Article.created_by_alias`, `Article`.`modified` AS `Article.modified`, `Article`.`modified_by` AS `Article.modified_by`, `Article`.`checked_out` AS `Article.checked_out`, `Article`.`checked_out_time` AS `Article.checked_out_time`, `Article`.`publish_up` AS `Article.publish_up`, `Article`.`publish_down` AS `Article.publish_down`, `Article`.`images` AS `Article.images`, `Article`.`urls` AS `Article.urls`, `Article`.`attribs` AS `Article.attribs`, `Article`.`version` AS `Article.version`, `Article`.`ordering` AS `Article.ordering`, `Article`.`metakey` AS `Article.metakey`, `Article`.`metadesc` AS `Article.metadesc`, `Article`.`access` AS `Article.access`, `Article`.`hits` AS `Article.hits`, `Article`.`metadata` AS `Article.metadata`, `Article`.`featured` AS `Article.featured`, `Article`.`language` AS `Article.language`, `Article`.`xreference` AS `Article.xreference`, `Extra`.`id` AS `Extra.id`, `Extra`.`article_id` AS `Extra.article_id`, `Extra`.`approved` AS `Extra.approved`, `Extra`.`approved_by` AS `Extra.approved_by`, `Extra`.`approve_time` AS `Extra.approve_time`, `Extra`.`category` AS `Extra.category`, `Extra`.`article_week` AS `Extra.article_week`, `Author`.`id` AS `Author.id`, `Author`.`name` AS `Author.name`, `Author`.`username` AS `Author.username`, `Author`.`email` AS `Author.email`, `Author`.`password` AS `Author.password`, `Author`.`block` AS `Author.block`, `Author`.`sendEmail` AS `Author.sendEmail`, `Author`.`registerDate` AS `Author.registerDate`, `Author`.`lastvisitDate` AS `Author.lastvisitDate`, `Author`.`activation` AS `Author.activation`, `Author`.`params` AS `Author.params`, `Author`.`lastResetTime` AS `Author.lastResetTime`, `Author`.`resetCount` AS `Author.resetCount`, `Author`.`otpKey` AS `Author.otpKey`, `Author`.`otep` AS `Author.otep` FROM `o7ge4_content` AS `Article` LEFT JOIN `o7ge4_content_extra` AS `Extra` ON `Extra`.`article_id` = 'Article.id' LEFT JOIN `o7ge4_users` AS `Author` ON `Article`.`created_by` = 'Author.id' WHERE `Article`.`catid` = '8' GROUP BY `Article`.`id`, `Article`.`id` ORDER BY `Article`.`created` LIMIT 30
    )


    When I typed the query code into PHPMyAdmin, it showed that all the fields for ModelID Extra contained NULL values, while the rest (Author and Article) contained the correct values.

    Please, if anyone has any idea about how I can solve this, kindly reply ASAP.

    Thanks in advance.
    mitey 06 Jan, 2014
    Also, there is another unrelated issue. I can't get the PHP functions to work.

    I'm trying to format a date field to my requirements. This is the code I am currently using:
    Article.created:return date("F j, Y", $cell)


    But I get the error below:
    Parse error: syntax error, unexpected '}' in \administrator\components\com_chronoconnectivity5\chronoconnectivity\helpers\lister.php(219) : runtime-created function on line 1
    Max_admin 06 Jan, 2014
    Hi,

    For the 2nd issue, please try this:
    Article.created:return date("F j, Y", $cell);


    For the 1st one, please try to use "article_id" in the foreign key and omit the join condition, the condition should work but it doesn't parse the main model id correctly for some reason, this needs further investigation!

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    mitey 07 Jan, 2014
    @Max, thanks for your help. The problems have been solved.

    Now, I have a new set of issues:

    The Edit, View, binary, New and Delete actions are not working.

    The Edit link shows 'Page not found' and this is the value when I hover
    /component/chronoconnectivity5/?cont=lists&ccname=Briefs&act=edit&gcb=3


    The New Toolbar Button shows an error message 'Connection's name not present!' and this is the url in the address bar
    /component/chronoconnectivity5/?cont=lists&act=edit&ccname=Briefs


    The Delete Toolbar button shows the same error message as the New button and this is the url in the address toolbar
    /component/chronoconnectivity5/?cont=lists&act=delete&ccname=Briefs


    The view action also has similar error message as above and this is the link on hover
    /component/chronoconnectivity5/?cont=lists&ccname=Briefs&act=view&gcb=3


    The binary toggle also has the same error message and this is the link
    /component/chronoconnectivity5/?cont=lists&act=toggle&ccname=Briefs&gcb=3&val=0&fld=state&model=Article


    So in essence only the edit action works(is without an error message), but the only content it brings is 'Page not found'. The rest give error message 'Connection not found'.

    Please note that I have already created a new form in CFv4 for new and edit. Also within the connection in CCv5 admin area, I have configured Front List > Actions > edit using brief:Load as Form event, with brief being the name of the form in CFv4.
    Max_admin 07 Jan, 2014
    Hi Mitey,

    Please contact me through the "Contact us" page to test a fix for this!

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    Max_admin 07 Jan, 2014
    And please note that CCV5 will only accept forms of CFv5, you can not use CFv4 forms with CCv5!

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    mitey 08 Jan, 2014
    @Max, I had problems installing CFv5. There is a problem installing CEGCore.

    So I extracted the installation package and installed only com_chronoforms5.zip. But now the admin area is not displaying properly. These are some of my screenshots. What could be wrong?

    [attachment=2]CFv5_0.png[/attachment]
    [attachment=1]CFv5_1.png[/attachment]
    [attachment=0]CFv5_2.png[/attachment]

    Also I am still developing the website on my local machine so it is not available for online viewing.

    Thanks for the help.
    mitey 10 Jan, 2014
    @vales, thanks for your help, I have been able to get CFv5 to work. Now the form is displaying a notice at the top

    Notice: Undefined offset: 1 in \administrator\components\com_chronoconnectivity5\chronoconnectivity\views\lists\edit.php on line 9



    Also, the textarea does not display a text editor which is very important in editing an article. Please @Max, what can be done about that?

    Also, the form only loads the fields from the main models. The others do not get displayed even though they appear on the listing.

    Thanks for your wonderful extension and support. I really appreciate it.
    mitey 13 Jan, 2014
    Please this is kind of urgent. Any way out?

    Thanks
    Max_admin 13 Jan, 2014
    Hi Mitey,

    Does your form fields names match the other models names ? e.g, name="Model2[name]"

    Regarding the editor, there is no field of type editor yet, but you may add this code into a custom code action at the top of the "on load" event, it may or may not work:
    
    <?php
    $doc = \GCore\Libs\Document::getInstance();
    $doc->_('editor');
    $doc->__('editor', '#FIELD_ID_HERE');
    


    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    mitey 13 Jan, 2014
    @max, thanks for replying. Yes I'm using the proper modelName[fieldName] format, but its not working. When I placed a debugger in the On Load event, this was the result of the data array
    Array
    (
        [cont] => lists
        [ccname] => Briefs
        [act] => edit
        [gcb] => 3
        [Article] => Array
            (
                [id] => 3
                [asset_id] => 67
                [title] => Amazon's drone delivery plan sparks privacy debate in United States
                [alias] => amazon-s-drone-delivery-plan-sparks-privacy-debate-in-united-states
                [introtext] => <p>...</p>
                [fulltext] => <p>...</p>
                [state] => 1
                [catid] => 8
                [created] => 2013-12-18 04:26:23
                [created_by] => 296
                [created_by_alias] => 
                [modified] => 2013-12-23 03:15:48
                [modified_by] => 294
                [checked_out] => 0
                [checked_out_time] => 0000-00-00 00:00:00
                [publish_up] => 2013-12-18 04:35:23
                [publish_down] => 0000-00-00 00:00:00
                [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
                [urls] => {"urla":false,"urlatext":"","targeta":"","urlb":false,"urlbtext":"","targetb":"","urlc":false,"urlctext":"","targetc":""}
                [attribs] => {"show_title":"","link_titles":"","show_tags":"","show_intro":"","info_block_position":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","urls_position":"","alternative_readmore":"","article_layout":"","show_publishing_options":"","show_article_options":"","show_urls_images_backend":"","show_urls_images_frontend":""}
                [version] => 5
                [ordering] => 1
                [metakey] => 
                [metadesc] => 
                [access] => 1
                [hits] => 28
                [metadata] => 
                [featured] => 0
                [language] => *
                [xreference] => 
            )
    
    )
    Array
    (
    )


    Also, the code you gave does not work; whether I place it before or after the Render Form action

    Thanks and Cheers!
    Max_admin 15 Jan, 2014
    Hi Mitey,

    Please contact me using the "Contact us" page for patches to fix these problems.

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    This topic is locked and no more replies can be posted.