Custom fields and filters of post

Started by davidhs, February 21, 2014, 01:53:17 PM

Previous topic - Next topic

davidhs

Quote from: jsismyrock on May 05, 2014, 04:19:54 PM
I will have to mess with it and see if it will work the way I need it.
Simple Image Upload add a link for upload images. When you click on this link, open a windows, you can search an image on your hard disk, click on ok, system upload your image to external image hosting (like imageshack, photobucker or tinypic, but I do nor remember name) and add in textarea this bbc
[img]http://image_on_external_host.ext[/img]

No upload images to your server.

spotlund

#41
This is an incredible mod that i would like to try but will not install through package manager.  I have tried to study how to manually install it and it seems like a lot of work.  Can we work to to try and get the package manager to install it?  Im also on 2.0.7 and get these failed


*    5.    Execute Modification    ./Sources/MessageIndex.php    Test failed
      6.    Replace    ./Sources/MessageIndex.php    Test failed
      9.    Add After    ./Sources/MessageIndex.php    Test failed

and everything else successful.

EDIT:

I have installed this through package manager even though it recommends not to.  It seems to be working like it should.  The only thing i am running into is after every filter or field it is putting text input below the label of the field


Westwegoman

#42
This seems to be just the mod that I need. I have a fishing forum and I would like to add fields for water temperature, air temperature etc... On certain boards. This would only have to show up on the first post of the topic and doesn't have to be visible on the message index.

I tried to install but seems to have a conflict with the global topics mod by Margarett. Before I go about trying to get it to work, will I have issues between the 2 mods and am I understanding correctly about what this mod does? I just want to add information to the body of the post.

EDIT: Doesn't seem to matter. I installed and it works without the 2 edits to message index. Didn't need those since I only want the info in the actual post anyway.

davidhs

Quote from: spotlund on May 17, 2014, 11:21:29 AM
This is an incredible mod that i would like to try but will not install through package manager.  I have tried to study how to manually install it and it seems like a lot of work.  Can we work to to try and get the package manager to install it?  Im also on 2.0.7 and get these failed


*    5.    Execute Modification    ./Sources/MessageIndex.php    Test failed
      6.    Replace    ./Sources/MessageIndex.php    Test failed
      9.    Add After    ./Sources/MessageIndex.php    Test failed

and everything else successful.

EDIT:

I have installed this through package manager even though it recommends not to.  It seems to be working like it should.  The only thing i am running into is after every filter or field it is putting text input below the label of the field
Quote from: spotlund on May 21, 2014, 10:41:17 AM
David when you get a chance, i have loaded the mod and seems to be working well.  Thanks for the build!  The only thing i truly have ran into is my fields and their inputs are on separate lines and not directly to the right of each other.  Can you point me in the direction to change this please? Both on the new topic and on the first post.

Thanks again.
Hi spotlund,

I paste here your PM because the problem is the same, and it can be usefull for others users.

I think package install fails on MessageIndex.php because you have installed others mods and they modify same file.

If you install with these errors, my mod can work with errors, I do not known.

Modifications on file MessageIndex.php are these:
<file name="$sourcedir/MessageIndex.php">
<operation>
<search position="before"><![CDATA[
loadTemplate('MessageIndex');
]]></search>
<add><![CDATA[
// BEGIN MOD CustomFieldFilterPost
loadTemplate('CustomFieldFilterPost');

if (isset($_REQUEST['cffp_filters']))
$_REQUEST['cffp'] = cffpUrlParamsDecompress($_REQUEST['cffp_filters']);
$context['cffp_filters']['params'] = isset($_REQUEST['cffp']) ? ';cffp_filters=' . cffpUrlParamsCompress($_REQUEST['cffp']) : '';

// Load filters of custom post fields.
cffpLoad(0, 0, 'filters');

$context['cffp_filters']['sql'] = cffpGetSqlFilter('filters');
// END MOD CustomFieldFilterPost
]]></add>
</operation>

<operation>
<search position="before"><![CDATA[
// How many topics do we have in total?
]]></search>
<add><![CDATA[ // BEGIN MOD CustomFieldFilterPost
if (!empty($context['cffp_filters']['sql']))
$board_info['total_topics'] = cffpGetTotalTopics();
else
// END MOD CustomFieldFilterPost
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start']]]></search>
<add><![CDATA[$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : '') /* BEGIN MOD CustomFieldFilterPost */ . $context['cffp_filters']['params'] /* END MOD CustomFieldFilterPost */, $_REQUEST['start']]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[$d', $_REQUEST['start']]]></search>
<add><![CDATA[$d' /* BEGIN MOD CustomFieldFilterPost */ . $context['cffp_filters']['params'] /* END MOD CustomFieldFilterPost */, $_REQUEST['start']]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[SELECT
t.id_topic]]></search>
<add><![CDATA[SELECT' /* BEGIN MOD CustomFieldFilterPost */ . (!empty($context['cffp_filters']['sql']) ? ' DISTINCT' : '') . /* END MOD CustomFieldFilterPost */ '
t.id_topic]]></add>
</operation>

<operation>
<search position="replace"><![CDATA['
WHERE ' . ($pre_query ? 't.id_topic IN ({array_int:topic_list})' : 't.id_board = {int:current_board}') . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')')]]></search>
<add><![CDATA[/* BEGIN MOD CustomFieldFilterPost */ (empty($context['cffp_filters']['sql']) ? '' : '
' . $context['cffp_filters']['sql']['from']) . /* END MOD CustomFieldFilterPost */ '
WHERE ' . ($pre_query ? 't.id_topic IN ({array_int:topic_list})' : 't.id_board = {int:current_board}') . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') /* BEGIN MOD CustomFieldFilterPost */ . (empty($context['cffp_filters']['sql']) ? '' : '
AND ' . $context['cffp_filters']['sql']['cond']) /* END MOD CustomFieldFilterPost */]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
array(
'current_board' => $board,
'current_member' => $user_info['id'],
'topic_list' => $topic_ids,
'is_approved' => 1,
'find_set_topics' => implode(',', $topic_ids),
'start' => $start,
'maxindex' => $maxindex,
)
]]></search>
<add><![CDATA[
// BEGIN MOD CustomFieldFilterPost
array_merge(!empty($context['cffp_filters']['sql']) ? $context['cffp_filters']['sql']['query_parameters'] : array(), array(
'current_board' => $board,
'current_member' => $user_info['id'],
'topic_list' => $topic_ids,
'is_approved' => 1,
'find_set_topics' => implode(',', $topic_ids),
'start' => $start,
'maxindex' => $maxindex,
)
)
// END MOD CustomFieldFilterPost
]]></add>
</operation>

<operation>
<search position="before"><![CDATA[
// Begin 'printing' the message index for current board.
]]></search>
<add><![CDATA[ // BEGIN MOD CustomFieldFilterPost
$id_msg_array = array();
// END MOD CustomFieldFilterPost
]]></add>
</operation>

<operation>
<search position="before"><![CDATA[
'unapproved_posts' => $row['unapproved_posts'],
);
]]></search>
<add><![CDATA[
// BEGIN MOD CustomFieldFilterPost
$id_msg_array[] = $context['topics'][$row['id_topic']]['first_post']['id'];
$context['cffp']['data_msg_topic'][$row['id_first_msg']] = array(
'sticky' => $context['topics'][$row['id_topic']]['is_sticky'] ? 1 : 0,
'locked' => $context['topics'][$row['id_topic']]['is_locked'] ? 1 : 0,
'id_msg' => $context['topics'][$row['id_topic']]['first_post']['id'],
'first_msg' => 1,
'subject' => $context['topics'][$row['id_topic']]['subject'],
);
// END MOD CustomFieldFilterPost
]]></add>
</operation>

<operation>
<search position="before"><![CDATA[
determineTopicClass($context['topics'][$row['id_topic']]);
}
$smcFunc['db_free_result']($result);
]]></search>
<add><![CDATA[
// BEGIN MOD CustomFieldFilterPost
// Load custom post fields.
cffpLoadValueOfFieldsByMsg($id_msg_array);
foreach ($context['topics'] as $t => $topic)
{
cffpLoad($topic['first_post']['id'], $topic['first_post']['member']['id'], 'message_index');
cffpLoad($topic['first_post']['id'], 0, 'message_index_member');
$context['topics'][$t]['first_post']['cffp']['message_index'] = $context['cffp']['message_index'];
$context['topics'][$t]['first_post']['cffp']['message_index_member'] = $context['cffp']['message_index_member'];
}
// END MOD CustomFieldFilterPost
]]></add>
</operation>
</file>

I recommend you to see which have not been applied and making them by hand.

About second problem, fields and their inputs are on separate lines and not directly to the right of each other, I think problems is CSS code (perhaps it was not copied when you install with errors, or you do not install on all themes.

Open your CSS file
FORUM_FOLDER/Themes/YOUR_THEME/css/index.css
and copy this code at end
/* BEGIN MOD CustomFieldFilterPost */
/* You do not modify this CSS style. Add your style before line "BEGIN MOD CustomFieldFilterPost" */
div.cffp_post,
div.cffp_member,
div.cffp_search
{
padding: 0.5em;
overflow: hidden;
}
div.cffp_post div.cffp_data,
div.cffp_member div.cffp_data,
div.cffp_search div.cffp_data
{
}
div.cffp_post dl.cffp_data dt,
div.cffp_member dl.cffp_data dt,
div.cffp_search dl.cffp_data dt
{
float: left;
padding: 0;
margin: .5em 0 0 0;
font-weight: bold;
clear: both;
}
div.cffp_post dl.cffp_data dd,
div.cffp_member dl.cffp_data dd,
div.cffp_search dl.cffp_data dd
{
float: left;
padding: 0;
margin: .3em 0;
}
div.cffp_post dl.cffp_data dt,
div.cffp_member dl.cffp_data dt
{
width: 20%;
}
div.cffp_post dl.cffp_data dd,
div.cffp_member dl.cffp_data dd
{
width: 78%;
}
div.cffp_search dl.cffp_data dt
{
width: 40%;
}
div.cffp_search dl.cffp_data dd
{
width: 58%;
}
form#cffp_edit_group .roundframe,
form#cffp_search .roundframe
{
padding: 0 12%;
}
div.cffp_post p.righttext,
div.cffp_member p.righttext
{
margin-top: 12px;
margin-bottom: 12px;
}
div.cffp_post .moderatorbar,
div.cffp_member .moderatorbar
{
margin: 0;
}
div.cffp_post ul.quickbuttons,
div.cffp_member ul.quickbuttons
{
}
div.cffp_member div.cffp_member_fields
{
border-bottom: 1px solid #c4c4c4;
}
div.cffp_member div.cffp_member_fields_first
{
border-top: 1px solid #c4c4c4;
}
div.cffp_member div.cffp_member_new_title
{
margin: 10px 0px;
}
div.cffp_member > fieldset legend a,
div.cffp_member div.cffp_member_data > fieldset legend a,
div.cffp_member div.cffp_member_new_title a
{
color: #444;
text-decoration: none;
}
div.cffp_member div.cffp_member_data_fields,
div.cffp_member div.cffp_member_new_fields
{
}
form#cffp_search div.cffp_column
{
margin: 0;
padding: 0;
width: 50%;
}
form#cffp_search div.cffp_column div.cffp_search
{
padding: 0 12px;
}
form#cffp_search div.cffp_roundframe
{
padding: 0 24%;
}
div.cffp_message_index,
div.cffp_message_index_member
{
}
div.cffp_message_index span,
div.cffp_message_index_member span
{
font-weight: bold;
margin-right: 1em;
}
div.cffp_message_index div.cffp_data,
div.cffp_message_index dl.cffp_data,
div.cffp_message_index dl.cffp_data dt,
div.cffp_message_index_member div.cffp_data,
div.cffp_message_index_member dl.cffp_data,
div.cffp_message_index_member dl.cffp_data dt
{
display: inline;
}
div.cffp_message_index dl.cffp_data dd,
div.cffp_message_index_member dl.cffp_data dd
{
display: inline-block;
margin-left: 0;
margin-right: 1em;
}
div.cffp_message_index_member div.cffp_member_fields
{
border-bottom: 1px solid #c4c4c4;
}
div.cffp_message_index_member div.cffp_member_fields_first
{
border-top: 1px solid #c4c4c4;
}
form#cffp_filters
{
margin-top: 1em;
}
form#cffp_filters div.cffp_filters span
{
font-weight: bold;
margin-right: 1em;
}
form#cffp_filters div.cffp_filters,
form#cffp_filters div.cffp_filters dl,
form#cffp_filters div.cffp_filters dt,
form#cffp_filters div.cffp_filters_button
{
display: inline;
}
form#cffp_filters div.cffp_filters dd
{
display: inline;
margin-left: 0;
margin-right: 1em;
}
ul.quickbuttons li.move_button
{
background: url(../images/icons/quick_move.gif) no-repeat 0 0;
}
/* END MOD CustomFieldFilterPost */







Quote from: Westwegoman on May 18, 2014, 11:36:49 PM
This seems to be just the mod that I need. I have a fishing forum and I would like to add fields for water temperature, air temperature etc... On certain boards. This would only have to show up on the first post of the topic and doesn't have to be visible on the message index.

I tried to install but seems to have a conflict with the global topics mod by Margarett. Before I go about trying to get it to work, will I have issues between the 2 mods and am I understanding correctly about what this mod does? I just want to add information to the body of the post.

EDIT: Doesn't seem to matter. I installed and it works without the 2 edits to message index. Didn't need those since I only want the info in the actual post anyway.
My mod works without the 2 edits to message index (it can be create unimportant warnings messages in logs). If you want applies by hand these 2 edit, read my reply to spotlund.

spotlund

I have double checked both of these and all is as you have said in both messageindex and index.css.

I even removed and readded everything in index.css.

davidhs

Quote from: spotlund on May 28, 2014, 09:05:55 AM
I have double checked both of these and all is as you have said in both messageindex and index.css.

I even removed and readded everything in index.css.
Can you put here an image of your forum? Or send to me by PM your forum url...

spotlund

website is hxxp:www.precisiontechsupport.com [nonactive] or hxxp:forums.precisiontechsupport.com [nonactive]

davidhs

Quote from: spotlund on May 28, 2014, 01:37:11 PM
website is www.precisiontechsupport.com or forums.precisiontechsupport.com
I visited your forum as guest. I did not see any post with custom fields but I saw index.css file and did not have this at the end (paste this at end of index.css)
/* BEGIN MOD CustomFieldFilterPost */
/* You do not modify this CSS style. Add your style before line "BEGIN MOD CustomFieldFilterPost" */
div.cffp_post,
div.cffp_member,
div.cffp_search
{
padding: 0.5em;
overflow: hidden;
}
div.cffp_post div.cffp_data,
div.cffp_member div.cffp_data,
div.cffp_search div.cffp_data
{
}
div.cffp_post dl.cffp_data dt,
div.cffp_member dl.cffp_data dt,
div.cffp_search dl.cffp_data dt
{
float: left;
padding: 0;
margin: .5em 0 0 0;
font-weight: bold;
clear: both;
}
div.cffp_post dl.cffp_data dd,
div.cffp_member dl.cffp_data dd,
div.cffp_search dl.cffp_data dd
{
float: left;
padding: 0;
margin: .3em 0;
}
div.cffp_post dl.cffp_data dt,
div.cffp_member dl.cffp_data dt
{
width: 20%;
}
div.cffp_post dl.cffp_data dd,
div.cffp_member dl.cffp_data dd
{
width: 78%;
}
div.cffp_search dl.cffp_data dt
{
width: 40%;
}
div.cffp_search dl.cffp_data dd
{
width: 58%;
}
form#cffp_edit_group .roundframe,
form#cffp_search .roundframe
{
padding: 0 12%;
}
div.cffp_post p.righttext,
div.cffp_member p.righttext
{
margin-top: 12px;
margin-bottom: 12px;
}
div.cffp_post .moderatorbar,
div.cffp_member .moderatorbar
{
margin: 0;
}
div.cffp_post ul.quickbuttons,
div.cffp_member ul.quickbuttons
{
}
div.cffp_member div.cffp_member_fields
{
border-bottom: 1px solid #c4c4c4;
}
div.cffp_member div.cffp_member_fields_first
{
border-top: 1px solid #c4c4c4;
}
div.cffp_member div.cffp_member_new_title
{
margin: 10px 0px;
}
div.cffp_member > fieldset legend a,
div.cffp_member div.cffp_member_data > fieldset legend a,
div.cffp_member div.cffp_member_new_title a
{
color: #444;
text-decoration: none;
}
div.cffp_member div.cffp_member_data_fields,
div.cffp_member div.cffp_member_new_fields
{
}
form#cffp_search div.cffp_column
{
margin: 0;
padding: 0;
width: 50%;
}
form#cffp_search div.cffp_column div.cffp_search
{
padding: 0 12px;
}
form#cffp_search div.cffp_roundframe
{
padding: 0 24%;
}
div.cffp_message_index,
div.cffp_message_index_member
{
}
div.cffp_message_index span,
div.cffp_message_index_member span
{
font-weight: bold;
margin-right: 1em;
}
div.cffp_message_index div.cffp_data,
div.cffp_message_index dl.cffp_data,
div.cffp_message_index dl.cffp_data dt,
div.cffp_message_index_member div.cffp_data,
div.cffp_message_index_member dl.cffp_data,
div.cffp_message_index_member dl.cffp_data dt
{
display: inline;
}
div.cffp_message_index dl.cffp_data dd,
div.cffp_message_index_member dl.cffp_data dd
{
display: inline-block;
margin-left: 0;
margin-right: 1em;
}
div.cffp_message_index_member div.cffp_member_fields
{
border-bottom: 1px solid #c4c4c4;
}
div.cffp_message_index_member div.cffp_member_fields_first
{
border-top: 1px solid #c4c4c4;
}
form#cffp_filters
{
margin-top: 1em;
}
form#cffp_filters div.cffp_filters span
{
font-weight: bold;
margin-right: 1em;
}
form#cffp_filters div.cffp_filters,
form#cffp_filters div.cffp_filters dl,
form#cffp_filters div.cffp_filters dt,
form#cffp_filters div.cffp_filters_button
{
display: inline;
}
form#cffp_filters div.cffp_filters dd
{
display: inline;
margin-left: 0;
margin-right: 1em;
}
ul.quickbuttons li.move_button
{
background: url(../images/icons/quick_move.gif) no-repeat 0 0;
}
/* END MOD CustomFieldFilterPost */

spotlund

thanks! i was only checking my default theme but it didnt make it to the theme that is set as default as well.

MESWEB

I need a setup mod that adds a field in a Wysiwyg to choose form. Example: I start a new thread and in Wysiwyg choose between the value of "a" - "f". I will chose the value "b" and this value is added automatically to topic. Is this possible?

davidhs

Quote from: MESWEB on June 21, 2014, 05:33:51 PM
I need a setup mod that adds a field in a Wysiwyg to choose form. Example: I start a new thread and in Wysiwyg choose between the value of "a" - "f". I will chose the value "b" and this value is added automatically to topic. Is this possible?
I am not sure what you want. You can add a radio buttom or select with options a, b, c, d, e, f and you will can select one option...

MESWEB

I don't need radio button. I need dropdown list. When I select one the value are added to topic name. Example drop down list:
1 Windows XP
2 Windows Vista
3 Windows 7

I chose 2 "Windows Vista"and write the subject "How to install?". When are finish post and click "post" then automatically "Windows Vista" is added to subect like "[Windows Vista] How to install?"

Is this possible

davidhs

Now this is not possible. Perhaps if you add javascript to a button (on next versions)... but now is not possible.

MESWEB


MrMike

Wow, I just came across this and I have to say that this is an extremely impressive mod. Good stuff. :)

Very nice work, thank you for making this!


MrMike

Quote from: davidhs on June 23, 2014, 08:25:17 AM
Now this is not possible. Perhaps if you add javascript to a button (on next versions)... but now is not possible.

Maybe a default handler could be added to some or all of the buttons/fields so that people could add their own JS functions to run when the button is pressed (or when the field is changed or focused/unfocused on).

Have it call a default javascript "do nothing" function, which could then be edited by the user to do whatever it is that  they want. For example, running some validation code or showing a dialog box, etc)

(I suppose you could also achieve the same effect via jQuery using the "Loading For SMF v1.0" mod, but it would be better to have it built in.)

I may not have explained this well, if so please let me know. It wouldn't be the first time. :)

davidhs

Quote from: MrMike on June 25, 2014, 08:37:37 PM
Quote from: davidhs on June 23, 2014, 08:25:17 AM
Now this is not possible. Perhaps if you add javascript to a button (on next versions)... but now is not possible.

Maybe a default handler could be added to some or all of the buttons/fields so that people could add their own JS functions to run when the button is pressed (or when the field is changed or focused/unfocused on).

Have it call a default javascript "do nothing" function, which could then be edited by the user to do whatever it is that  they want. For example, running some validation code or showing a dialog box, etc)

(I suppose you could also achieve the same effect via jQuery using the "Loading For SMF v1.0" mod, but it would be better to have it built in.)

I may not have explained this well, if so please let me know. It wouldn't be the first time. :)
You do not worry, soon I update this MOD with some enhancements, and I will add possibility to add JavaScript code in groups of fields :)

luuuciano

Hola David!

I have installed your mod, and have been trying to use it... but maybe I do not quite understand it...
I have created a few fields, asigned them to a forum, did a simple output template... and then?
Well, then I went to that forum... clicked over the New post button... and nothing... nothing changed, nothing new... just the regular smf stuff...

The main idea is that I will see those new fields there, right?
To fill them... and then after submit the post, the template will show them?

What can be wrong?
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

davidhs

Are you check permissions for users and actions? All groups and fields have permissions section at bottom of page. All are unckecked by default.

If you have problems, made images of your settings and post with custom groups of fields.

luuuciano

Quote from: davidhs on July 08, 2014, 08:30:08 AM
Are you check permissions for users and actions? All groups and fields have permissions section at bottom of page. All are unckecked by default.

I think I did... here a couple of screenshots:







Any idea?
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

Advertisement: