Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Two Joomla questions on custom fields

Hi, all.  I'm a newbie to joomla and have run into a couple of problems with custom fields.

Using the guidelines found at http://forum.joomla.org/viewtopic.php?f=428&t=352285 (working solution is at bottom of page 2) I have successfully added several custom fields to a joomla site.  They display and update fine.  Now, I need to do 2 other things and can't figure them out:
1) Add data validation when a new article is added.
2) Convert 3 of the text boxes to select lists.

1) Page /libraries/joomla/database/table/content.php has a function named "Check()" that appears to validate the other (standard) article fields. Example:
if(empty($this->title)) {
$this->setError(JText::_('Article must have a title'));
return false;
}
However, if I edit the function by copying this code and changing the field name ("title") to one of my custom fields ("url"), I get a 500 error if "url" is left blank. This tells me the test is working but "setError" is not doing what I expected.  I'd like to use the same "alert" type validation that joomla uses, but how do I add?

2) Working on /administrator/components/com_content/admin.content.html.php, three of the new fields need to be changed from text boxes to select lists.  The values to include in the list of options are in tables in the joomla database.  When I try to make a new connection to the db to run the query, I get "Error Loading Modules" message at the top of the page and, in the "Parameters" area, the following error message:
Warning: Invalid argument supplied for foreach() in [*site root removed*]/libraries/joomla/html/html/select.php on line 68.  

The db connect is good because I tested on a blank page, and I've not touched the page referenced by the error.  

I'm assuming that joomla already has a db connection established, so I could use that if I knew the variable.  In any case, what do I do to connect and run my queries for the select options?

Any help deeply appreciated!  If more info needed, just ask.

Bruce
0
springthorpeSoftware
Asked:
springthorpeSoftware
  • 4
  • 2
1 Solution
 
Amanda WatsonCommented:
I am not 100% clear what you are trying to achieve exactly.....

Your configuration.php file will contain the information to the database that is being used to run joomla which is in the root folder
0
 
springthorpeSoftwareAuthor Commented:
snowball77,
Thank you so much for replying!

I have added fields to the jos_content table and I am trying to (1) validate what is entered for those fields when article is added/edited via the admin Article Manager and, if validation fails, display an alert and (2) trying to connect to another table in the same database to retrieve the option list for a "select" pull-down list for some other of those custom fields.

For (2), it's not that I don't know how to connect to the db or don't have the connection parameters, but that Joomla is throwing what is, from the surface, a totally unrelated error when I attempt to assign the db connection to a variable via PHP, e.g.
  [...assign values to connection variables...]
  $artDBC=mysql_connect($artHostname, $artUsername, $artPassword);
  $grpSQL = "SELECT DISTINCT grpGroup FROM artGroups ORDER BY grpGroup";
  $grpQry = mysql_query ($grpSQL,$artDBC);
The error shown by Joomla is in my original post and occurs when the mysql_connect function is called.

The page where I'm attempting the new database connection is  ../administrator/components/com_content/admin.content.html.php

Hope I'm making sense...  Let me know if you need further info.
Thanks again,
Bruce
0
 
springthorpeSoftwareAuthor Commented:
Attached screen shot may help explain error I'm seeing.
Bruce
Errors.png
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Amanda WatsonCommented:
So you have customised the Article Editing area to add more fields and have now got errors...
Or is there an extension you have used to do this?

You might want to tag this question to more experts in PHP.

Sorry I can't be more helpful
0
 
springthorpeSoftwareAuthor Commented:
No, did not use an extension.  

Yes, the article editing has been customized, but everything works fine when the new fields are displayed as text boxes.  The problems came into play when (1) trying to validate the new fields and (2) trying to convert 3 of those text fields into <select> lists with options retrieved from a query.  

I'm not an expert with PHP, but do know my way around it, so I don't think it's a PHP issue.  More related to how Joomla! is constructed/operates.

Thanks for trying.  Can anyone else take a shot at it?
Bruce
0
 
springthorpeSoftwareAuthor Commented:
OK, problem with db connection is now fixed.  I was trying to establish a second connection to the database when Joomla! already had one open.  By assuming that the connection was already there and using the default connection, I was able to query for the <options>.

Consider this one closed.  Will re-post the validation question if I still need to.

Thanks!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now