Add a new field to an article
Moderator: Thorsten
-
- Posts: 10
- Joined: Tue Jul 07, 2009 11:31 pm
Add a new field to an article
Can anyone tell me what needs to be done to add a new field to an article?
I need to add a few new fields to accomodate our requirements but I am not sure
where to start. Is there any documentation or can someone tell me how to do this.
I need to add a few new fields to accomodate our requirements but I am not sure
where to start. Is there any documentation or can someone tell me how to do this.
Re: Add a new field to an article
Hi,
this is a bigger change... but not too complicated if you know PHP. You should read the source code of the main FAQ class in inc/Faq.php and should try it.
bye
Thorsten
this is a bigger change... but not too complicated if you know PHP. You should read the source code of the main FAQ class in inc/Faq.php and should try it.
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
-
- Posts: 10
- Joined: Tue Jul 07, 2009 11:31 pm
Re: Add a new field to an article
Thanks. Could you point me to what lines relate to the article add,edit,view,and delete? I do know php and
need to add a new field to all those areas of the script. Is there any documentation that might explain how
to do this or do I just have to dig thru the code?
need to add a new field to all those areas of the script. Is there any documentation that might explain how
to do this or do I just have to dig thru the code?
Re: Add a new field to an article
Hi,
in the admin backend it's all about admin/record.*.php. The main class is inc/Faq.php with the PMF_Faq class. There are some add and delete methods in the class. The architecture is quite simple.
bye
Thorsten
in the admin backend it's all about admin/record.*.php. The main class is inc/Faq.php with the PMF_Faq class. There are some add and delete methods in the class. The architecture is quite simple.
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
-
- Posts: 10
- Joined: Tue Jul 07, 2009 11:31 pm
Re: Add a new field to an article
Ok I have it working as far as the Creation/Insert of a new article. I cant get it to work on the update of an article.
When I edit an article i have it showing up in the form and in preview hidden form variables but when i click save
it does not work. In faq.php in the updateRecord function i added the new field to update statement and to the data array
but when i do that it seems to break the script. can you advise how to make this work please? I have created the field in
both the data and revisions table as well.
When I edit an article i have it showing up in the form and in preview hidden form variables but when i click save
it does not work. In faq.php in the updateRecord function i added the new field to update statement and to the data array
but when i do that it seems to break the script. can you advise how to make this work please? I have created the field in
both the data and revisions table as well.
Re: Add a new field to an article
Hi,
can you please show me your changes?
bye
Thorsten
can you please show me your changes?
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
-
- Posts: 10
- Joined: Tue Jul 07, 2009 11:31 pm
Re: Add a new field to an article
There ar eall the changes so far I have made for adding a new field short_title.
!!!!! OPEN admin/record_edit.php !!!!!!
REPLACE:
WITH:
ADD WHERE NEW FIELD SHOULD SHOW UP:
!!!!! OPEN admin/record.save.php !!!!!!
REPLACE:
WITH:
REPLACE:
WITH:
!!!!! OPEN inc/faq.php !!!!!!!
LOCATE: function addRecord
IN THE INSERT STATEMENT ADD A '%s' on the end of the values.
FOR EACH NEW FIELD ADD AN ENTRY FOLLOWING THE LAST DATA ENTRY. BE
SURE TO MOVE THE ); TO THE END OF THE DATA LISTS AND ADD AN APPROPRIATE
SEPERATING COMMAs.
locate getRecord function
1. APPEND EACH NEW FIELD NAME INTO THE SELECT STATEMENT
2. APPEND EACH NEW FIELD INTO the two faqRecord arrays
+_+_+_+_+_NOT WORKING YET FOR UPDATE.
--------------------------------------------------------------
LOCATE: function updateRecord
1. APPEND EACH NEW FIELD NAME INTO THE UPDATE SET STATEMENT
EXAMPLE: fieldname = '%s'
2. APPEND EACH NEW FIELD INTO the data array
FOR EACH NEW FIELD ADD AN ENTRY FOLLOWING THE LAST FIELD. BE
SURE ADD APPROPRIATE SEPERATING COMMAs.
!!!!! OPEN admin/record_edit.php !!!!!!
REPLACE:
Code: Select all
$faqData['keywords'] = $_REQUEST["keywords"];
Code: Select all
$faqData['keywords'] = $_REQUEST["keywords"];
$faqData['short_title'] = $_REQUEST["short_title"];
Code: Select all
<label class="lefteditor" for="cust_short_title">Short Title</label>
<input name="short_title" id="short_title" style="width: 390px;" value="<?php if (isset($faqData['short_title'])) { print htmlspecialchars($faqData['short_title']); } ?>" /><br />
REPLACE:
Code: Select all
<input type="hidden" name="keywords" value="<?php print $_REQUEST['keywords']; ?>" />
Code: Select all
<input type="hidden" name="keywords" value="<?php print $_REQUEST['keywords']; ?>" />
<input type="hidden" name="short_title" value="<?php print $_REQUEST['short_title']; ?>" />
REPLACE:
Code: Select all
'keywords' => $db->escape_string($_POST['keywords']),
Code: Select all
'keywords' => $db->escape_string($_POST['keywords']),
'short_title' => $db->escape_string($_POST['short_title']),
!!!!! OPEN inc/faq.php !!!!!!!
LOCATE: function addRecord
IN THE INSERT STATEMENT ADD A '%s' on the end of the values.
FOR EACH NEW FIELD ADD AN ENTRY FOLLOWING THE LAST DATA ENTRY. BE
SURE TO MOVE THE ); TO THE END OF THE DATA LISTS AND ADD AN APPROPRIATE
SEPERATING COMMAs.
Code: Select all
$data['cust_short_title'],
locate getRecord function
1. APPEND EACH NEW FIELD NAME INTO THE SELECT STATEMENT
2. APPEND EACH NEW FIELD INTO the two faqRecord arrays
+_+_+_+_+_NOT WORKING YET FOR UPDATE.
--------------------------------------------------------------
LOCATE: function updateRecord
1. APPEND EACH NEW FIELD NAME INTO THE UPDATE SET STATEMENT
EXAMPLE: fieldname = '%s'
2. APPEND EACH NEW FIELD INTO the data array
FOR EACH NEW FIELD ADD AN ENTRY FOLLOWING THE LAST FIELD. BE
SURE ADD APPROPRIATE SEPERATING COMMAs.
Code: Select all
fieldname = '%s'
Re: Add a new field to an article
clarityproductions wrote: LOCATE: function updateRecord
Code: Select all
/**
* Updates a record
*
* @param array $data
* @return boolean
* @access public
* @since 2006-06-18
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function updateRecord($data)
{
if (!is_array($data)) {
return false;
}
// Update entry
$query = sprintf("
UPDATE
%sfaqdata
SET
revision_id = %d,
active = '%s',
keywords = '%s',
cust_short_title = '%s',
thema = '%s',
content = '%s',
author = '%s',
email = '%s',
comment = '%s',
datum = '%s',
links_state = '%s',
links_check_date = %d,
date_start = '%s',
date_end = '%s'
WHERE
id = %d
AND
lang = '%s'",
SQLPREFIX,
$data['revision_id'],
$data['active'],
$data['keywords'],
$data['cust_short_title'],
$data['thema'],
$data['content'],
$data['author'],
$data['email'],
$data['comment'],
$data['date'],
$data['linkState'],
$data['linkDateCheck'],
$data['dateStart'],
$data['dateEnd'],
$data['id'],
$data['lang']);
$this->db->query($query);
return true;
}
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist