News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Custom fields and filters of post

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

Previous topic - Next topic

davidhs

I saw the problem. :)

Groups has properties
- Show on the first post of topic / Mostrar en el primer mensaje del tema
- Show on the replies of topic / Mostrar en las respuestas del tema
and these are unchecked by default.

You must check some of these and you will see your group on first post and/or replies.

On next update I will change this and these properties will be checked by default.

luuuciano

Quote from: davidhs on July 09, 2014, 08:12:24 AM
You must check some of these and you will see your group on first post and/or replies.

Oops, thanks! :)
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

New version:
1.1     2014-07-17
------------------
! In WYSIWYG mode, if the user add a record and the post body is empty, the system did not write a period (".") on it.
! If a field with radio buttons or checkboxes is defined as "Not empty value" and is left blank, no error was displayed.
! Each posted data on groups of type "fields with several values per member" must be moved individually, not all from the message at once.
! Languages: english, english-utf8.
+ Support for print topic.
+ Field in administration panel to add BBC before the record when entering data.
+ Field in administration panel to add JavaScript code when a group of fields is created or modified.
+ Field in administration panel to add HTML before and after the input button and the output text in a custom field.
+ Field in administration panel to show expanded the most recent posted data in groups of type "fields with several values per member".
+ Field in administration panel to show most recent posted data at the top in groups of type "fields with several values per member".
+ Field in administration panel to indicate the maximum height of the area with posted data in groups of type "fields with several values per member".
+ Field in administration panel to show, in the member profile, a list for each group of type "record", with posted messages by the member containing this type of group.
+ Field in administration panel to control, in the Moderation Center, the content posted by users in the groups of type "fields with several values per member".
* Field in administration panel to indicate if a group will be show on the first post of topic is selected by default.
* Field in administration panel to indicate if a group will be show on the replies of topic is selected by default.
+ Quick input field to fill the fields when a record is created.
+ Variable in "Show enclosed within text" to insert ID of the current message.
+ Variable in "Show enclosed within text" to insert field name in database of any custom field.
+ PHP function in "Show enclosed within text" to display a group of a message like in a message or like on the message index.
+ Variable in templates to insert ID of the current message.
+ Variable in templates to insert field name in database of any custom field.
+ PHP function in templates to display a group of a message like in a message or like on the message index.
+ In administration panel is shown each group and field ID.
+ Text field to add multiple options at one time when a custom field with options is created or modified in administration panel.
* Big multi-line text input fields are wider.
* Submit buttons have shortcut key to get focus.
+ SMF compatibility: 2.0.8.

MESWEB

Installation error nr.9:
'
LEFT JOIN {db_prefix}best_answer AS `ba` ON `t`.`id_topic` = `ba`.`id_topic`
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}') . ')') . '

davidhs

Quote from: MESWEB on July 19, 2014, 11:16:17 AM
Installation error nr.9:
'
LEFT JOIN {db_prefix}best_answer AS `ba` ON `t`.`id_topic` = `ba`.`id_topic`
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}') . ')') . '

This code are not installed by my mod (I write my text between
/* BEGIN MOD CustomFieldFilterPost */ ... /* END MOD CustomFieldFilterPost */

Are you sure the problem is my mod? Attach your php file and I will see.

MESWEB

Quote from: MESWEB on July 19, 2014, 11:16:17 AM
Installation error nr.9:
'
LEFT JOIN {db_prefix}best_answer AS `ba` ON `t`.`id_topic` = `ba`.`id_topic`
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}') . ')') . '


This is are existing code. I need replace: 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}') . ')')

But when I replace the code I got error php.

davidhs

#66
Quote from: MESWEB on July 19, 2014, 06:57:47 PM
Quote from: MESWEB on July 19, 2014, 11:16:17 AM
Installation error nr.9:
'
LEFT JOIN {db_prefix}best_answer AS `ba` ON `t`.`id_topic` = `ba`.`id_topic`
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}') . ')') . '


This is are existing code. I need replace: 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}') . ')')

But when I replace the code I got error php.

We have a problem :( You have installed "Best Answer" and "NiceTooltips" mods. These mods do changes on MessageIndex.php and my mod do changes on same code.

You can not install these mods without errors. If you want install my mod you can to do these.

0. I suppose you have installed "Best Answer" and "NiceTooltips" mods.

1. Install my mod with errors. You must to have 2 errors on MessageIndex.php (actions #6 and #9)

2. You do these manual changes on MessageIndex.php.

2.1. Action #6, 1st part -> Search (line 388)

LEFT JOIN {db_prefix}best_answer AS `ba` ON `t`.`id_topic` = `ba`.`id_topic`

and replace by

LEFT JOIN {db_prefix}best_answer AS `ba` ON `t`.`id_topic` = `ba`.`id_topic`' . /* BEGIN MOD CustomFieldFilterPost */ (empty($context['cffp_filters']['sql']) ? '' : '
' . $context['cffp_filters']['sql']['from']) . /* END MOD CustomFieldFilterPost */ '


2.2. Action #6, 2nd part -> Search (line 391)

AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . '

and replace by

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 */ . '


2.3. Action #9 -> Search (line 547)

'unapproved_posts' => $row['unapproved_posts'],
'best_answer' => array(
'id_msg' => $row['best_answer'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['best_answer'] . '#msg' . $row['best_answer']
),
);

and replace by

'unapproved_posts' => $row['unapproved_posts'],
'best_answer' => array(
'id_msg' => $row['best_answer'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['best_answer'] . '#msg' . $row['best_answer']
),
);

// 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


But... if you uninstall my mod, you need undo these changes.

MESWEB

Something is wrong with code.
QuoteParse error: syntax error, unexpected '.' in /Sources/MessageIndex.php on line 406

I just delete dot from end of comment
Quote/* END MOD CustomFieldFilterPost */ . '

Is this correct?

davidhs

Quote from: MESWEB on July 20, 2014, 11:14:15 AM
Something is wrong with code.
QuoteParse error: syntax error, unexpected '.' in /Sources/MessageIndex.php on line 406

I just delete dot from end of comment
Quote/* END MOD CustomFieldFilterPost */ . '

Is this correct?
Yes, of course. It is a typo. :-[ (I correct on previous post)

MESWEB

Ok thanks.

How to delete large empty space?
How to add value from selected list to subject? Like: [Windows XP] How to install?

davidhs

Quote from: MESWEB on July 20, 2014, 12:52:03 PM
How to delete large empty space?
Modify CSS file (YOUR_FORUM/Themes/default/css/index.css). Go to at end of file. This control width of fieldset
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%;
}

- cffp_post is for a record or field loose
- cffp_member is for a group with several values per member
- dt is space of field name
- dd is space of field button
total width must be around 98% (not 100%). i.e dt 20% + dd 78% = 98%

For example, you can rewrite this like
div.cffp_post dl.cffp_data dt,
div.cffp_member dl.cffp_data dt
{
width: 15%;
}
div.cffp_post dl.cffp_data dd,
div.cffp_member dl.cffp_data dd
{
width: 83%;
}

or others values.

Quote from: MESWEB on July 20, 2014, 12:52:03 PM
How to add value from selected list to subject? Like: [Windows XP] How to install?
You see example on first message of this topic. You can add JavaScript code to a group of fields.

Your select button "System" has ID like "cffp_X_column_Y" (see source code). This copy value of select button checked to your subject:
document.getElementById("cffp_X_column_Y").onchange = function (event)
{
document.getElementsByName("subject")[0].value = this.value;
}


With JavaScript can to do many things when an event occurs over a button (value is changed, loose focus, get focus, is checked,...):
- Update value of others buttons.
- Hide/show fields.
- Write text on subject or body of message.
- Change icon.
- ...
but is necessary know JavaScript and HTML, of course.

MESWEB

Quote from: davidhs on July 20, 2014, 03:12:54 PM
Modify CSS file (YOUR_FORUM/Themes/default/css/index.css). Go to at end of file. This control width of fieldset
But when You use different Theme go to other catalog.
Quote from: davidhs on July 20, 2014, 03:12:54 PM
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%;
}

What happens if I will use 7 % + 78% = 85%. Does it cause any errors in displaying?
Quote from: davidhs on July 20, 2014, 03:12:54 PM
You see example on first message of this topic. You can add JavaScript code to a group of fields.

Your select button "System" has ID like "cffp_X_column_Y" (see source code). This copy value of select button checked to your subject:
document.getElementById("cffp_X_column_Y").onchange = function (event)
{
document.getElementsByName("subject")[0].value = this.value;
}

How to put a square bracket to:
Quotedocument.getElementById("cffp_X_column_Y").onchange = function (event)

davidhs

Quote from: MESWEB on July 20, 2014, 06:08:30 PM
Quote from: davidhs on July 20, 2014, 03:12:54 PM
Modify CSS file (YOUR_FORUM/Themes/default/css/index.css). Go to at end of file. This control width of fieldset
But when You use different Theme go to other catalog.
You should modify CSS of your theme.

Quote from: MESWEB on July 20, 2014, 06:08:30 PM
Quote from: davidhs on July 20, 2014, 03:12:54 PM
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%;
}

What happens if I will use 7 % + 78% = 85%. Does it cause any errors in displaying?
No cause error. Width will be 7% (label) + 78% (buttons) + 15% (space).

Quote from: MESWEB on July 20, 2014, 06:08:30 PM
Quote from: davidhs on July 20, 2014, 03:12:54 PM
You see example on first message of this topic. You can add JavaScript code to a group of fields.

Your select button "System" has ID like "cffp_X_column_Y" (see source code). This copy value of select button checked to your subject:
document.getElementById("cffp_X_column_Y").onchange = function (event)
{
document.getElementsByName("subject")[0].value = this.value;
}

How to put a square bracket to:
Quotedocument.getElementById("cffp_X_column_Y").onchange = function (event)
Do you not found keys "[ ]" on your keyboard? In each country or language is different.

MESWEB

Quote from: davidhs on July 20, 2014, 06:42:58 PM
Do you not found keys "[ ]" on your keyboard? In each country or language is different.

Questions
1. You don't understand me  ;D. I need to add "[ ]" automatic. Example - when You select "Windows XP" from drop down list then subject looks like " [ Windows XP ] "
2. When I first write subject and next select from drop down list then subject is gone. Is there any chance to change this?
3. Is it possible to force a user to chose from drop down list? If he does not select then warning message popup should be displayed.

davidhs

 :-[ :D

Quote from: MESWEB on July 21, 2014, 10:25:06 AM
Questions
1. You don't understand me  ;D. I need to add "[ ]" automatic. Example - when You select "Windows XP" from drop down list then subject looks like " [ Windows XP ] "
2. When I first write subject and next select from drop down list then subject is gone. Is there any chance to change this?
3. Is it possible to force a user to chose from drop down list? If he does not select then warning message popup should be displayed.
1. Easy... (+ is for concatenate strings in JavaScript)
document.getElementById("cffp_X_column_Y").onchange = function (event)
{
document.getElementsByName("subject")[0].value = "[" + this.value + "]";
}


2. This change subject only if is empty.
document.getElementById("cffp_X_column_Y").onchange = function (event)
{
if ("" == document.getElementsByName("subject")[0].value)
document.getElementsByName("subject")[0].value = "[" + this.value + "]";
}


3. Yes. 8) Edit field settings in Administrator Panel. Check Advanced settings > Not empty value. This shows a warning in red color like when subject or body is leave empty.
Also you can check a default option.

Westwegoman

#75
I just noticed that I get a database error when I try to search posts.

QuoteNot unique table/alias: 't'
File: /community/Sources/Subs-CustomFieldFilterPost.php
Line: 879

Also in error log, the following:
QuoteDatabase Error: Not unique table/alias: 't'
File: /community/Sources/Subs-CustomFieldFilterPost.php
Line: 879
Quote8: Undefined index: can_approve_posts
File: /community/Sources/Subs-CustomFieldFilterPost.php
Line: 1592


Westwegoman

Ok. Something strange. It doesn't give error on my test forum. Maybe a problem on my regular forum from something else.

davidhs

Quote from: Westwegoman on August 21, 2014, 09:01:23 AM
Ok. Something strange. It doesn't give error on my test forum. Maybe a problem on my regular forum from something else.
I have a bug in Subs-CustomFieldFilterPost.php of mod version 1.1. This is only executed when you have checked "approve any posts before they are shown".


I soon will update to version 1.2 with more bugs fixed and many enhancements. :)

At this moment you can fixed this bug with RAR attached. I suppose you have installed last version (1.1) of my mod. In this archive you can see two files:

smf2.0-2.0.7/Subs-CustomFieldFilterPost.php -- replace your file with this if your forum is SMF 2.0 to 2.0.7
smf2.0.8-2.0.99/Subs-CustomFieldFilterPost.php -- replace your file with this if your forum is SMF 2.0.8

kak2z

Hello. Thanks for a very useful mod.
I receive an error
Quote
index.php?board=114.0;a4f33eb90=9ed6e40691d1c80b6d518e174edc5de8Undefined index: can_approve_posts
/Sources/Subs-CustomFieldFilterPost.php
line: 1626
After you install this mod I could not install modification Karma Post Rating
I made these changes.



$context['page_index'] = constructPageIndex($scripturl . '?action=profile;u=' . $memID . ';area=showposts' . ($context['is_topics'] ? ';sa=topics' : '') . (!empty($board) ? ';board=' . $board : '') . (!empty($context['kpr_profile_sort']) ? ';rating' : '') . ((!empty($context['kpr_profile_sort']) && $context['kpr_profile_sort'] == 'rating_time') ? '=time' : '') . (!empty($context['kpr_profile_sort_desc']) ? ';desc' : '') , $context['start'], $msgCount, $maxIndex);


need
$context['page_index'] = constructPageIndex($scripturl . '?action=profile;u=' . $memID . ';area=showposts' . ($context['is_topics'] ? ';sa=topics' : '') . /* BEGIN MOD CustomFieldFilterPost */ ($context['is_cffp_record'] ? ';sa=cffp_record_' . $context['is_cffp_record'] : '') . /* END MOD CustomFieldFilterPost */ (!empty($board) ? ';board=' . $board : ''), $context['start'], $msgCount, $maxIndex);

my changes
$context['page_index'] = constructPageIndex($scripturl . '?action=profile;u=' . $memID . ';area=showposts' . ($context['is_topics'] ? ';sa=topics' : '') . /* BEGIN MOD CustomFieldFilterPost */ ($context['is_cffp_record'] ? ';sa=cffp_record_' . $context['is_cffp_record'] : '') . /* END MOD CustomFieldFilterPost */ (!empty($board) ? ';board=' . $board : '') . (!empty($context['kpr_profile_sort']) ? ';rating' : '') . ((!empty($context['kpr_profile_sort']) && $context['kpr_profile_sort'] == 'rating_time') ? '=time' : '') . (!empty($context['kpr_profile_sort_desc']) ? ';desc' : '') , $context['start'], $msgCount, $maxIndex);


Новости и слухи Дом 2. Популярные рецепты в рубрике Что приготовить

Advertisement: