Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Now Available => Topic started by: babjusi on July 31, 2008, 04:24:42 PM

Title: [Tip&trick] Vb postbit
Post by: babjusi on July 31, 2008, 04:24:42 PM
Recently I made this for someone here who asked me. It displays the post info at the topic view in a bordered way, vb style. Which I think it's a more organized look and will be effective in every post on your forum. That guy had seen it at another forum, not smf, and asked me to port it over to his smf forum as well. So, I did that and I thought to share it here as well.


Here we go.

First of all make a backup of the files before you apply the changes

Add the following set of code all the way to the bottom of the style.css file in your theme''s directory

.memdetails {
    padding-top: 3px;
    padding-right: 0px;
    padding-bottom: 3px;
    padding-left: 3px;
    margin: 3px 0px 3px 3px;
    background-color: #fafcfe;
    border-top: 1px solid #686868 ;
    border-right: 1px solid #686868 ;
    border-left: 3px solid #686868 ;
    border-bottom: 1px solid #686868;
}       


Save the changes and re-upload the file back overwriting the old one.

Next, upload the Display.template.php file from your /Themes/ directory  to your pc and open it with a decent php editor program and find the following code:

// Show the member's custom title, if they have one.
      if (isset($message['member']['title']) && $message['member']['title'] != '')
         echo '
                        ', $message['member']['title'], '<br />';



Change it to:

// Show the member's custom title, if they have one.
      if (isset($message['member']['title']) && $message['member']['title'] != '')
         echo '
                        <div class="memdetails">', $message['member']['title'], '</div>';



Find:

// Show the member's primary group (like 'Administrator') if they have one.
      if (isset($message['member']['group']) && $message['member']['group'] != '')
         echo '
                        ', $message['member']['group'], '<br />';



Change it to:

// Show the member's primary group (like 'Administrator') if they have one.
      if (isset($message['member']['group']) && $message['member']['group'] != '')
         echo '
                        <div class="memdetails">', $message['member']['group'], '</div>';



Find:

// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
         if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
            echo '
                        ', $message['member']['post_group'], '<br />';
         echo '
                        ', $message['member']['group_stars'], '<br />';



Change it to:

// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
         if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
            echo '
                        <div class="memdetails">', $message['member']['post_group'], '</div>';
         echo '
                        <div class="memdetails">', $message['member']['group_stars'], '</div>';




Find:

// Is karma display enabled?  Total or +/-?
         if ($modSettings['karmaMode'] == '1')
            echo '
                        <br />
                        ', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '<br />';
         elseif ($modSettings['karmaMode'] == '2')
            echo '
                        <br />
                        ', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '<br />';


Change it to:

// Is karma display enabled?  Total or +/-?
         if ($modSettings['karmaMode'] == '1')
            echo '
                       
                        <div class="memdetails">', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '</div>';
         elseif ($modSettings['karmaMode'] == '2')
            echo '
                        <div class="memdetails">', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '</div>';



Find:

// Show online and offline buttons?
         if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
            echo '
                        ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', $settings['use_image_buttons'] ? '<img src="' . $message['member']['online']['image_href'] . '" alt="' . $message['member']['online']['text'] . '" border="0" style="margin-top: 2px;" />' : $message['member']['online']['text'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $message['member']['online']['text'] . '</span>' : '', '<br /><br />';


Change it to:

// Show online and offline buttons?
         if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
            echo '
                        <div class="memdetails">', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', $settings['use_image_buttons'] ? '<img src="' . $message['member']['online']['image_href'] . '" alt="' . $message['member']['online']['text'] . '" border="0" style="margin-top: 2px;" />' : $message['member']['online']['text'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $message['member']['online']['text'] . '</span>' : '', '<br /></div>';



Find:

// Show how many posts they have made.
         echo '
                        ', $txt[26], ': ', $message['member']['posts'], '<br />
                        <br />';



Change it to:

// Show how many posts they have made.
         echo '
                        <div class="memdetails">', $txt[26], ': ', $message['member']['posts'], '</div>';



Find:

// Show their personal text?
         if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
            echo '
                        ', $message['member']['blurb'], '<br />
                        <br />';


Change it to:

// Show their personal text?
         if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
            echo '
                        <div class="memdetails">', $message['member']['blurb'], '</div>
                        <br />';



That was it. Save the changes and re-upload the file back overwriting the old one. Personally I do think that this looks very nice on topic view. But you can judge by yourself based on the screenshot attached.

Here is like it looks in action. This is for the 1.1. series


The mod version can be found here

http://custom.simplemachines.org/mods/index.php?mod=1371

Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: Hoochie Coochie Man on August 02, 2008, 03:54:32 PM
Very nice, thanks..
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: Eliana Tamerin on August 04, 2008, 09:30:05 AM
Indexed.
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: ormuz on August 25, 2008, 02:38:45 PM
How to add this trick to custom profile mod?
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: babjusi on August 25, 2008, 02:43:41 PM
Quote from: ormuz on August 25, 2008, 02:38:45 PM
How to add this trick to custom profile mod?

I am not sure that I understood you. What is is exactly that you mean or want to accomplish by doing that? Because this has nothing to do with the custom profile mod.
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: ormuz on August 25, 2008, 02:58:54 PM
Quote from: babjusi on August 25, 2008, 02:43:41 PM
Quote from: ormuz on August 25, 2008, 02:38:45 PM
How to add this trick to custom profile mod?

I am not sure that I understood you. What is is exactly that you mean or want to accomplish by doing that? Because this has nothing to do with the custom profile mod.

Costum profile mod (http://custom.simplemachines.org/mods/index.php?mod=319) add the ability to add costum fields to the postbit on the display.template.php

I just want to add this trick (the memdetails div) to the field that I have in my postbit

this is the code from the mod in the display template, how to add this trick to the mod?
              global $sourcedir, $messagevars;
$messagevars = $message;
require_once($sourcedir . '/CustomProfile.php');
DisplayFieldPosts();
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: babjusi on August 26, 2008, 05:57:07 AM
Quote from: ormuz on August 25, 2008, 02:58:54 PM
Quote from: babjusi on August 25, 2008, 02:43:41 PM
Quote from: ormuz on August 25, 2008, 02:38:45 PM
How to add this trick to custom profile mod?

I am not sure that I understood you. What is is exactly that you mean or want to accomplish by doing that? Because this has nothing to do with the custom profile mod.

Costum profile mod (http://custom.simplemachines.org/mods/index.php?mod=319) add the ability to add costum fields to the postbit on the display.template.php

I just want to add this trick (the memdetails div) to the field that I have in my postbit

this is the code from the mod in the display template, how to add this trick to the mod?
              global $sourcedir, $messagevars;
$messagevars = $message;
require_once($sourcedir . '/CustomProfile.php');
DisplayFieldPosts();


I don''t think you can add this through the custom profile mod.
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: Eliana Tamerin on August 26, 2008, 09:31:59 AM
You could if you arranged the styling in CustomProfile.php.
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: ormuz on August 26, 2008, 03:17:36 PM
Quote from: Eliana Tamerin on August 26, 2008, 09:31:59 AM
You could if you arranged the styling in CustomProfile.php.

I ask that in the mod support topic, but a smf moderator remove my doubt there...
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: ccbtimewiz on August 26, 2008, 04:05:33 PM
Try out this:

echo '<div class="memdetails">', DisplayFieldPosts(), '</div>';
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: ormuz on August 26, 2008, 07:00:10 PM
Quote from: ccbtimewiz on August 26, 2008, 04:05:33 PM
Try out this:

echo '<div class="memdetails">', DisplayFieldPosts(), '</div>';

That was my first try, and it works! But if the custom field is empty, it show the div too... Any ideas?
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: ccbtimewiz on August 26, 2008, 07:03:52 PM
Quote from: ormuz on August 26, 2008, 07:00:10 PM
Quote from: ccbtimewiz on August 26, 2008, 04:05:33 PM
Try out this:

echo '<div class="memdetails">', DisplayFieldPosts(), '</div>';

That was my first try, and it works! But if the custom field is empty, it show the div too... Any ideas?

Yes.

if( DisplayFieldPosts() = true ) { echo '<div class="memdetails">', DisplayFieldPosts(), '</div>'; }
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: babjusi on August 27, 2008, 08:54:58 AM
Quote from: Eliana Tamerin on August 26, 2008, 09:31:59 AM
You could if you arranged the styling in CustomProfile.php.

Maybe, I am not familiar with the mod in question.
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: Eliana Tamerin on August 27, 2008, 10:07:24 AM
Quote from: ormuz on August 26, 2008, 07:00:10 PM
Quote from: ccbtimewiz on August 26, 2008, 04:05:33 PM
Try out this:

echo '<div class="memdetails">', DisplayFieldPosts(), '</div>';

That was my first try, and it works! But if the custom field is empty, it show the div too... Any ideas?

No need to do anything more, the user figured it out.
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: babjusi on September 01, 2008, 12:24:51 PM
This has been released as a mod now

http://custom.simplemachines.org/mods/index.php?mod=1371
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: ccbtimewiz on September 01, 2008, 12:30:56 PM
Perhaps a better title would be better... borderdataontopicview is kinda off the tongue. :P
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: babjusi on September 01, 2008, 12:48:17 PM
Quote from: ccbtimewiz on September 01, 2008, 12:30:56 PM
Perhaps a better title would be better... borderdataontopicview is kinda off the tongue. :P

It could be, but at the moment when I made it couldn''t find a better name for it :D
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: ormuz on September 01, 2008, 04:35:33 PM
The name shloud be "Vb postbit"
Title: Re: [Tip&trick] Bordered Post Data in Topic View
Post by: babjusi on September 03, 2008, 08:08:50 AM
Quote from: ormuz on September 01, 2008, 04:35:33 PM
The name shloud be "Vb postbit"

I like that.
Title: Re: [Tip&trick] Vb postbit
Post by: Smoky "Rider" Blue on September 05, 2008, 12:19:22 AM
you did a great job with this babjusi, thanks for sharing! :)
Title: Re: [Tip&trick] Vb postbit
Post by: Heartlander on September 07, 2008, 03:20:23 PM
Can anyone please answer the question regarding the purpose of this mod?
Thanks.
Title: Re: [Tip&trick] Vb postbit
Post by: babjusi on September 07, 2008, 03:38:50 PM
Quote from: Heartlander on September 07, 2008, 03:20:23 PM
Can anyone please answer the question regarding the purpose of this mod?
Thanks.

I have explained it in the first post of the topic. For more info have a look at the screenshot attached under my very first post :)
Title: Re: [Tip&trick] Vb postbit
Post by: matasanos on September 19, 2008, 04:29:17 AM
please someone knows how to add a bordered way but all items in a div element..
i hope i had explained well..sorry for my bad english.
Title: Re: [Tip&trick] Vb postbit
Post by: Oldiesmann on October 19, 2008, 01:05:59 AM
Do you still need help with this matasanos?
Title: Re: [Tip&trick] Vb postbit
Post by: Futbolero90 on February 08, 2009, 03:07:54 PM
=S i´ve installed this mod, without problems, but the postbit still looking like the default post bit :S
check: http://fifaps3xtreme.co.cc/index.php?topic=2.0
i have to activate this mod in the adminpanel or something like that?
grettings from México
and sorry my bad english

Edit:
its ok now, excelent mod :D
Title: Re: [Tip&trick] Vb postbit
Post by: DakOon on February 10, 2009, 07:40:29 PM
Very nice, thanks...
Title: Re: [Tip&trick] Vb postbit
Post by: chrislittle09 on February 11, 2009, 02:00:33 AM
thanks for your post.
Title: Re: [Tip&trick] Vb postbit
Post by: SilverKnight on March 29, 2009, 07:51:38 PM
This is now a mod.. should probably be moved.
Title: Re: [Tip&trick] Vb postbit
Post by: Smoky "Rider" Blue on March 29, 2009, 09:32:05 PM
it's now my mod Silverknight  ;)
Title: Re: [Tip&trick] Vb postbit
Post by: JBlaze on April 24, 2009, 08:05:32 PM
Quote from: SmokyBlue on March 29, 2009, 09:32:05 PM
it's now my mod Silverknight  ;)

Nice job Smoky :)
Title: Re: [Tip&trick] Vb postbit
Post by: Smoky "Rider" Blue on April 24, 2009, 08:14:01 PM
thanks Jblaze.. i took over it for Babjusi..  ;)
Title: Re: [Tip&trick] Vb postbit
Post by: JBlaze on April 24, 2009, 09:27:34 PM
Quote from: SmokyBlue on April 24, 2009, 08:14:01 PM
thanks Jblaze.. i took over it for Babjusi..  ;)

Stealing is not nice.... :P
Title: Re: [Tip&trick] Vb postbit
Post by: Smoky "Rider" Blue on April 24, 2009, 10:27:16 PM
lmao i didnt steal it, Babjusi gave me all his mods.. he wanted me to have them JBlaze..  8)
Title: Re: [Tip&trick] Vb postbit
Post by: JBlaze on April 24, 2009, 10:55:46 PM
Quote from: SmokyBlue on April 24, 2009, 10:27:16 PM
lmao i didnt steal it, Babjusi gave me all his mods.. he wanted me to have them JBlaze..  8)

mhm....

lol
Title: Re: [Tip&trick] Vb postbit
Post by: Smoky "Rider" Blue on April 24, 2009, 11:28:19 PM


                                         :P
Title: Re: [Tip&trick] Vb postbit
Post by: _F3R_ on September 22, 2009, 02:37:47 PM
Hello guys, I install the custom profile field mod and the  Vb postbit.
in the posts the custom profile field mod doesn't work when vbpostbit.
This is display.template.php

global $sourcedir, $messagevars;
$messagevars = $message;
require_once($sourcedir . '/CustomProfile.php');
DisplayFieldPosts();

// Show how many posts they have made.
echo '
<div class="windowbg4">', $txt[26], ': ', $message['member']['posts'], '</div>';


the class of vbpostbit is <div class="windowbg4">

and this is custom profile.php

<?php

if (!defined('SMF'))
die('Hacking attempt...');

function 
EditFields()
{
global $context$modSettings;
$i 1;
while (isset($modSettings['enable_CP' $i '']))
{
if ($modSettings['enable_CP' $i ''])
{
if ($modSettings['CP' $i '_edit'] && !$context['user']['is_admin'])
{
$i++;
continue;
}
if ($modSettings['CP' $i '_hr'] == 'edit' || $modSettings['CP' $i '_hr'] == 'summary_edit')
{
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>'
;
}
if ($modSettings['CP' $i '_type']=='text')
{
echo '
<tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b>' , !empty($modSettings['CP' $i '_desc']) ? '<div class="smalltext">' $modSettings['CP' $i '_desc'] . '</div>' '' '</td><td><input type="text" name="default_options[' $modSettings['CP' $i '_id'] . ']" size="50" value="', @$context['member']['options'][$modSettings['CP' $i '_id']], '" /></td>
</tr>'
;
}
if ($modSettings['CP' $i '_type']=='textarea')
{
echo '
<tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b>' , !empty($modSettings['CP' $i '_desc']) ? '<div class="smalltext">' $modSettings['CP' $i '_desc'] . '</div>' '' '</td><td><textarea name="default_options[' $modSettings['CP' $i '_id'] . ']" rows="4" cols="80" class="editor">', @$context['member']['options'][$modSettings['CP' $i '_id']], '</textarea></td>
</tr>'
;
}
if ($modSettings['CP' $i '_type']=='select')
{
echo '
<tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b>' , !empty($modSettings['CP' $i '_desc']) ? '<div class="smalltext">' $modSettings['CP' $i '_desc'] . '</div>' '' '</td>
<td><select name="default_options[' 
$modSettings['CP' $i '_id'] . ']">';
$r 1;
while (isset($modSettings['CP' $i '_data' $r '']) && !empty($modSettings['CP' $i '_data' $r '']))
{
if (isset($context['member']['options'][$modSettings['CP' $i '_id']]) && $context['member']['options'][$modSettings['CP' $i '_id']] == $modSettings['CP' $i '_data' $r ''])
{
echo '
<option selected="selected">' 
$modSettings['CP' $i '_data' $r ''] . '</option>';
}
else
{
echo '
<option>' 
$modSettings['CP' $i '_data' $r ''] . '</option>';
}
$r++;
}
echo '
</select></td>'
;
}
if ($modSettings['CP' $i '_type']=='check')
{
echo '
<tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b>' , !empty($modSettings['CP' $i '_desc']) ? '<div class="smalltext">' $modSettings['CP' $i '_desc'] . '</div>' '' '</td><td><input type="hidden" name="default_options[' $modSettings['CP' $i '_id'] . ']" value="0" /><input type="checkbox" name="default_options[' $modSettings['CP' $i '_id'] . ']" value="1"', @$context['member']['options'][$modSettings['CP' $i '_id']] ? ' checked="checked"' ''' class="check" /></td>
</tr>'
;
}
}
$i++;
}
}

function 
RegistrationFields()
{
global $context$modSettings;
$i 1;
while (isset($modSettings['enable_CP' $i '']))
{
if ($modSettings['enable_CP' $i ''] && $modSettings['CP' $i '_reg'])
{
if ($modSettings['CP' $i '_type']=='text')
{
echo '
<tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b>' , !empty($modSettings['CP' $i '_desc']) ? '<div class="smalltext">' $modSettings['CP' $i '_desc'] . '</div>' '' '</td><td><input type="text" name="default_options[' $modSettings['CP' $i '_id'] . ']" size="50" value="', @$context['member']['options'][$modSettings['CP' $i '_id']], '" /></td>
</tr>'
;
}
if ($modSettings['CP' $i '_type']=='textarea')
{
echo '
<tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b>' , !empty($modSettings['CP' $i '_desc']) ? '<div class="smalltext">' $modSettings['CP' $i '_desc'] . '</div>' '' '</td><td><textarea name="default_options[' $modSettings['CP' $i '_id'] . ']" rows="4" cols="80" class="editor">', @$context['member']['options'][$modSettings['CP' $i '_id']], '</textarea></td>
</tr>'
;
}
if ($modSettings['CP' $i '_type']=='select')
{
echo '
<tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b>' , !empty($modSettings['CP' $i '_desc']) ? '<div class="smalltext">' $modSettings['CP' $i '_desc'] . '</div>' '' '</td>
<td><select name="default_options[' 
$modSettings['CP' $i '_id'] . ']">';
$r 1;
while (isset($modSettings['CP' $i '_data' $r '']) && !empty($modSettings['CP' $i '_data' $r '']))
{
if (isset($context['member']['options'][$modSettings['CP' $i '_id']]) && $context['member']['options'][$modSettings['CP' $i '_id']] == $modSettings['CP' $i '_data' $r ''])
{
echo '
<option selected="selected">' 
$modSettings['CP' $i '_data' $r ''] . '</option>';
}
else
{
echo '
<option>' 
$modSettings['CP' $i '_data' $r ''] . '</option>';
}
$r++;
}
echo '
</select></td>'
;
}
if ($modSettings['CP' $i '_type']=='check')
{
echo '
<tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b>' , !empty($modSettings['CP' $i '_desc']) ? '<div class="smalltext">' $modSettings['CP' $i '_desc'] . '</div>' '' '</td><td><input type="hidden" name="default_options[' $modSettings['CP' $i '_id'] . ']" value="0" /><input type="checkbox" name="default_options[' $modSettings['CP' $i '_id'] . ']" value="1"', @$context['member']['options'][$modSettings['CP' $i '_id']] ? ' checked="checked"' ''' class="check" /></td>
</tr>'
;
}
}
$i++;
}
}

function 
CheckFieldInput()
{
global $modSettings$txt$forum_version;
$i 1;
while (isset($modSettings['enable_CP' $i '']))
{
if ($modSettings['enable_CP' $i ''] && $modSettings['CP' $i '_reg']=='force' && empty($_POST['default_options'][$modSettings['CP' $i '_id']]))
{
loadLanguage('CustomProfile');
$txt['cp_regerror'] = preg_replace('/FIELDNAME/'$modSettings['CP' $i '_name'], $txt['cp_regerror']);
fatal_lang_error('cp_regerror'false);
}
$i++;
}

// The strings aren't cleaned properly on registration.
if (version_compare($forum_version'1.1.5') != 1)
{
if (isset($_POST['default_options']))
$_POST['default_options'] = htmlspecialchars__recursive($_POST['default_options']);
if (isset($_POST['options']))
$_POST['options'] = htmlspecialchars__recursive($_POST['options']);
}
}

function 
DisplayFieldPosts()
{
global $context$modSettings$messagevars;
$i 1;
while (isset($modSettings['enable_CP' $i '']))
{
if ($modSettings['enable_CP' $i ''] && isset($messagevars['member']['options'][$modSettings['CP' $i '_id']]) && !empty($messagevars['member']['options'][$modSettings['CP' $i '_id']]) && $modSettings['CP' $i '_post'])
{
if ($modSettings['CP' $i '_view'] && !$context['user']['is_admin'])
{
$i++;
continue;
}
if ($modSettings['CP' $i '_type']=='text' || $modSettings['CP' $i '_type']=='textarea')
{
if ($modSettings['CP' $i '_post']!='text')
{
$i++;
continue;
}
$before preg_replace('/%1/'$messagevars['member']['options'][$modSettings['CP' $i '_id']], $modSettings['CP' $i '_data1']);
$after preg_replace('/%1/'$messagevars['member']['options'][$modSettings['CP' $i '_id']], $modSettings['CP' $i '_data2']);
if ($modSettings['CP' $i '_bbc'])
{
$field parse_bbc($before $messagevars['member']['options'][$modSettings['CP' $i '_id']] . $after);
}
else
{
$field $before $messagevars['member']['options'][$modSettings['CP' $i '_id']] . $after;
}
echo '
$modSettings['CP' $i '_name'] . ': ' $field '<br />';
}
if ($modSettings['CP' $i '_type']=='select')
{
if ($modSettings['CP' $i '_bbc'])
{
$field parse_bbc($messagevars['member']['options'][$modSettings['CP' $i '_id']]);
}
else
{
$field $messagevars['member']['options'][$modSettings['CP' $i '_id']];
}
echo '
$modSettings['CP' $i '_name'] . ': ' $field '<br />';
}
if ($modSettings['CP' $i '_type']=='check')
{
if ($modSettings['CP' $i '_bbc'])
{
$modSettings['CP' $i '_data1'] = parse_bbc($modSettings['CP' $i '_data1']);
$modSettings['CP' $i '_data2'] = parse_bbc($modSettings['CP' $i '_data2']);
}
if ($messagevars['member']['options'][$modSettings['CP' $i '_id']])
{
echo '
$modSettings['CP' $i '_name'] . ': ' $modSettings['CP' $i '_data1'] . '<br />';
}
else
{
echo '
$modSettings['CP' $i '_name'] . ': ' $modSettings['CP' $i '_data2'] . '<br />';
}
}
}
$i++;
}
}

function 
DisplayFieldPostsPictures()
{
global $context$modSettings$messagevars;
$i 1;
while (isset($modSettings['enable_CP' $i '']))
{
if ($modSettings['enable_CP' $i ''] && isset($messagevars['member']['options'][$modSettings['CP' $i '_id']]) && !empty($messagevars['member']['options'][$modSettings['CP' $i '_id']]) && $modSettings['CP' $i '_post'])
{
if ($modSettings['CP' $i '_view'] && !$context['user']['is_admin'])
{
$i++;
continue;
}
if ($modSettings['CP' $i '_type']=='text' || $modSettings['CP' $i '_type']=='textarea')
{
if ($modSettings['CP' $i '_post']!='image')
{
$i++;
continue;
}
$before preg_replace('/%1/'$messagevars['member']['options'][$modSettings['CP' $i '_id']], $modSettings['CP' $i '_data1']);
$after preg_replace('/%1/'$messagevars['member']['options'][$modSettings['CP' $i '_id']], $modSettings['CP' $i '_data2']);
if ($modSettings['CP' $i '_bbc'])
{
$field parse_bbc($before $messagevars['member']['options'][$modSettings['CP' $i '_id']] . $after);
}
else
{
$field $before $messagevars['member']['options'][$modSettings['CP' $i '_id']] . $after;
}
echo $field;
}
}
$i++;
}
}

function 
DisplayFieldsProfile()
{
global $context$modSettings;
$i 1;
while (isset($modSettings['enable_CP' $i '']))
{
if ($modSettings['enable_CP' $i ''] && isset($context['member']['options'][$modSettings['CP' $i '_id']]) && !empty($context['member']['options'][$modSettings['CP' $i '_id']]) && $modSettings['CP' $i '_profile'])
{
if ($modSettings['CP' $i '_view'] && !$context['user']['is_admin'])
{
$i++;
continue;
}
if ($modSettings['CP' $i '_hr'] == 'edit' || $modSettings['CP' $i '_hr'] == 'summary_edit')
{
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>'
;
}
if ($modSettings['CP' $i '_type']=='text' || $modSettings['CP' $i '_type']=='textarea')
{
$before preg_replace('/%1/'$context['member']['options'][$modSettings['CP' $i '_id']], $modSettings['CP' $i '_data1']);
$after preg_replace('/%1/'$context['member']['options'][$modSettings['CP' $i '_id']], $modSettings['CP' $i '_data2']);
if ($modSettings['CP' $i '_bbc'])
{
$context['member']['options'][$modSettings['CP' $i '_id']] = parse_bbc($before $context['member']['options'][$modSettings['CP' $i '_id']] . $after);
}
else
{
$context['member']['options'][$modSettings['CP' $i '_id']] = $before $context['member']['options'][$modSettings['CP' $i '_id']] . $after;
}
echo '
</tr><tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b></td>
<td>' 
$context['member']['options'][$modSettings['CP' $i '_id']] . '</td>';
}
if ($modSettings['CP' $i '_type']=='select')
{
if ($modSettings['CP' $i '_bbc'])
{
$field parse_bbc($context['member']['options'][$modSettings['CP' $i '_id']]);
}
else
{
$field $context['member']['options'][$modSettings['CP' $i '_id']];
}
echo '
</tr><tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b></td>
<td>' 
$field '</td>';
}
if ($modSettings['CP' $i '_type']=='check')
{
if ($modSettings['CP' $i '_bbc'])
{
$modSettings['CP' $i '_data1'] = parse_bbc($modSettings['CP' $i '_data1']);
$modSettings['CP' $i '_data2'] = parse_bbc($modSettings['CP' $i '_data2']);
}
if ($context['member']['options'][$modSettings['CP' $i '_id']])
{
echo '
</tr><tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b></td>
<td>' 
$modSettings['CP' $i '_data1'] . '</td>';
}
else
{
echo '
</tr><tr>
<td><b>' 
$modSettings['CP' $i '_name'] . ': </b></td>
<td>' 
$modSettings['CP' $i '_data2'] . '</td>';
}
}
}
$i++;
}
}

function 
CustomFieldSettings()
{
global $txt$scripturl$context$settings$sc$modSettings$txt;
loadLanguage('CustomProfile');

if (isset($_GET['cp']))
{
if ($modSettings['CP' $_GET['cp'] . '_type']=='text' || $modSettings['CP' $_GET['cp'] . '_type']=='textarea')
{
$cp $_GET['cp'];
$config_vars = array(
array('text''CP' $cp '_name'null$txt['cp_name']),
array('text''CP' $cp '_desc'null$txt['cp_desc']),
array('check''CP' $cp '_profile'null$txt['cp_profileshow']),
array('select''CP' $cp '_post', array('0' => $txt['cp_dontshow'], 'text' => $txt['cp_underpostcount'], 'image' => $txt['cp_underimages'],), $txt['cp_showposts']),
array('check''CP' $cp '_bbc'null$txt['cp_parsebbc']),
array('text''CP' $cp '_data1'null$txt['cp_before']),
array('text''CP' $cp '_data2'null$txt['cp_after']),
array('text''CP' $cp '_id'null$txt['cp_fieldid']),
array('select''CP' $cp '_hr', array('no' => $txt['cp_dontshow'], 'summary' => $txt['cp_hrsummary'], 'edit' => $txt['cp_hredit'], 'summary_edit' => $txt['cp_onboth'],), $txt['cp_hrule']),
array('select''CP' $cp '_reg', array('0' => $txt['cp_dontshow'], 'opt' => $txt['co_optinput'], 'force' => $txt['cp_forceinput'],), $txt['cp_showreg']),
array('check''CP' $cp '_edit'null$txt['cp_adminedit']),
array('check''CP' $cp '_view'null$txt['cp_adminview']),
'<a href="' $scripturl '?action=featuresettings;sa=profile;addfield=' $cp ';sesc=' $sc '">' $txt['cp_recreate'] . '</a>',
);
}
elseif ($modSettings['CP' $_GET['cp'] . '_type']=='check')
{
$cp $_GET['cp'];
$config_vars = array(
array('text''CP' $cp '_name'null$txt['cp_name']),
array('text''CP' $cp '_desc'null$txt['cp_desc']),
array('check''CP' $cp '_profile'null$txt['cp_profileshow']),
array('check''CP' $cp '_post'null$txt['cp_showposts']),
array('text''CP' $cp '_data1'null$txt['cp_checked']),
array('text''CP' $cp '_data2'null$txt['cp_notchecked']),
array('check''CP' $cp '_bbc'null$txt['cp_parsebbc']),
array('text''CP' $cp '_id'null$txt['cp_fieldid']),
array('select''CP' $cp '_hr', array('no' => $txt['cp_dontshow'], 'summary' => $txt['cp_hrsummary'], 'edit' => $txt['cp_hredit'], 'summary_edit' => $txt['cp_onboth'],), $txt['cp_hrule']),
array('select''CP' $cp '_reg', array('0' => $txt['cp_dontshow'], 'opt' => $txt['cp_show'],), $txt['cp_showreg']),
array('check''CP' $cp '_edit'null$txt['cp_adminedit']),
array('check''CP' $cp '_view'null$txt['cp_adminview']),
'<a href="' $scripturl '?action=featuresettings;sa=profile;addfield=' $cp ';sesc=' $sc '">' $txt['cp_recreate'] . '</a>',
);
}
elseif ($modSettings['CP' $_GET['cp'] . '_type']=='select')
{
$cp $_GET['cp'];
$config_vars = array(
array('text''CP' $cp '_name'null$txt['cp_name']),
array('text''CP' $cp '_desc'null$txt['cp_desc']),
array('check''CP' $cp '_profile'null$txt['cp_profileshow']),
array('check''CP' $cp '_post'null$txt['cp_showposts']),
array('check''CP' $cp '_bbc'null$txt['cp_parsebbc']),
array('text''CP' $cp '_id'null$txt['cp_fieldid']),
array('select''CP' $cp '_hr', array('no' => $txt['cp_dontshow'], 'summary' => $txt['cp_hrsummary'], 'edit' => $txt['cp_hredit'], 'summary_edit' => $txt['cp_onboth'],), $txt['cp_hrule']),
array('select''CP' $cp '_reg', array('0' => $txt['cp_dontshow'], 'opt' => $txt['cp_show'],), $txt['cp_showreg']),
array('check''CP' $cp '_edit'null$txt['cp_adminedit']),
array('check''CP' $cp '_view'null$txt['cp_adminview']),
);
$i 1;
while (isset($modSettings['CP' $cp '_data' $i '']))
{
$cp_option preg_replace('/OPTIONNUMBER/'$i$txt['cp_option']);
$config_vars[] = array('text''CP' $cp '_data'$i ''null$cp_option);
$i++;
}
$config_vars[] = '<a href="' $scripturl '?action=featuresettings;sa=profile;adddata=' $cp ';sesc=' $sc '">' $txt['cp_addoption'] . '</a>';
$config_vars[] = '<a href="' $scripturl '?action=featuresettings;sa=profile;addfield=' $cp ';sesc' $sc '">' $txt['cp_recreate'] . '</a>';
}
}
elseif (isset($_GET['addfield']))
{
checkSession('get');

$settings = array(
'enable_CP' $_GET['addfield'] . '' => '1',
'CP' $_GET['addfield'] . '_name' => $txt['cp_unnamed'],
'CP' $_GET['addfield'] . '_desc' => '',
'CP' $_GET['addfield'] . '_type' => 'text',
'CP' $_GET['addfield'] . '_post' => '0',
'CP' $_GET['addfield'] . '_profile' => '1',
'CP' $_GET['addfield'] . '_bbc' => '0',
'CP' $_GET['addfield'] . '_data1' => '',
'CP' $_GET['addfield'] . '_data2' => '',
'CP' $_GET['addfield'] . '_id' => 'CP' $_GET['addfield'] . '',
'CP' $_GET['addfield'] . '_hr' => '0',
'CP' $_GET['addfield'] . '_reg' => '0',
'CP' $_GET['addfield'] . '_edit' => '0',
'CP' $_GET['addfield'] . '_view' => '0',
);
addSettings($settings);
redirectexit('action=featuresettings;sa=profile');
}
elseif (isset($_GET['adddata']))
{
checkSession('get');

$i 1;
while (isset($modSettings['CP' $_GET['adddata'] . '_data' $i]))
$i++;
$settings = array(
'CP' $_GET['adddata'] . '_data' $i => '',
);
addSettings($settings);
redirectexit('action=featuresettings;sa=profile;cp=' $_GET['adddata']);
}
elseif (isset($_GET['moveup']))
{
checkSession('get');

moveUp($_GET['moveup']);
redirectexit('action=featuresettings;sa=profile');
}
elseif (isset($_GET['movedown']))
{
checkSession('get');

moveDown($_GET['movedown']);
redirectexit('action=featuresettings;sa=profile');
}
elseif (isset($_GET['delete']))
{
checkSession('get');

deleteField($_GET['delete']);
redirectexit('action=featuresettings;sa=profile');
}
else
{
$config_vars = array();
$i 1;
while (isset($modSettings['enable_CP' $i]))
{
$n $i 1;
if ($n 1)
{
$config_vars[] = '<a href="' $scripturl '?action=featuresettings;sa=profile;cp=' $n '">' $txt['cp_settings'] . '</a> <a href="' $scripturl '?action=featuresettings;sa=profile;moveup=' $n ';sesc=' $sc '">' $txt['cp_moveup'] . '</a> <a href="' $scripturl '?action=featuresettings;sa=profile;movedown=' $n ';sesc=' $sc '">' $txt['cp_movedown'] . '</a> <a href="' $scripturl '?action=featuresettings;sa=profile;delete=' $n ';sesc=' $sc '">' $txt['cp_delete'] . '</a>';
$config_vars[] = '';
}
elseif ($n 0)
{
$config_vars[] = '<a href="' $scripturl '?action=featuresettings;sa=profile;cp=' $n '">' $txt['cp_settings'] . '</a> <a href="' $scripturl '?action=featuresettings;sa=profile;movedown=' $n ';sesc=' $sc '">' $txt['cp_movedown'] . '</a> <a href="' $scripturl '?action=featuresettings;sa=profile;delete=' $n ';sesc=' $sc '">' $txt['cp_delete'] . '</a>';
$config_vars[] = '';
}
$cp_enable preg_replace('/FIELDNAME/'$modSettings['CP' $i '_name'], $txt['cp_enable']);
$config_vars[] = array('check''enable_CP' $i ''null$cp_enable);
$config_vars[] = array('select''CP' $i '_type', array('text' => $txt['cp_text'], 'textarea' => $txt['cp_textarea'], 'check' => $txt['cp_checkbox'], 'select' => $txt['cp_selectbox'],), $txt['cp_type']);
$i++;
}
$n $i 1;
if ($n 1)
{
$config_vars[] = '<a href="' $scripturl '?action=featuresettings;sa=profile;cp=' $n '">' $txt['cp_settings'] . '</a> <a href="' $scripturl '?action=featuresettings;sa=profile;moveup=' $n ';sesc=' $sc '">' $txt['cp_moveup'] . '</a> <a href="' $scripturl '?action=featuresettings;sa=profile;delete=' $n ';sesc=' $sc '">' $txt['cp_delete'] . '</a>';
$config_vars[] = '';
}
elseif ($n == 1)
{
$config_vars[] = '<a href="' $scripturl '?action=featuresettings;sa=profile;cp=' $n '">' $txt['cp_settings'] . '</a> <a href="' $scripturl '?action=featuresettings;sa=profile;delete=' $n ';sesc=' $sc '">' $txt['cp_delete'] . '</a>';
$config_vars[] = '';
}
$txt['cp_addfield'] = preg_replace('/FIELDNUMBER/'$i$txt['cp_addfield']);
$config_vars[] = '<a href="' $scripturl '?action=featuresettings;sa=profile;addfield=' $i ';sesc=' $sc '">' $txt['cp_addfield'] . '</a>';
}

if (isset($_GET['save']))
{
saveDBSettings($config_vars);
redirectexit('action=featuresettings;sa=profile');
}

if (isset($_GET['cp']))
{
$txt['cp_fieldsettings'] = preg_replace('/FIELDNUMBER/'$_GET['cp'], $txt['cp_fieldsettings']);
$context['settings_title'] = $txt['cp_fieldsettings'];
$context['post_url'] = $scripturl '?action=featuresettings2;save;sa=profile;cp=' $_GET['cp'] .'';
}
else
{
$context['settings_title'] = $txt['cp_cpfields'];
$context['post_url'] = $scripturl '?action=featuresettings2;save;sa=profile';
}

prepareDBSettingContext($config_vars);
}

function 
addSettings($settings$overwrite false)
{
global $db_prefix;

$string '';
foreach ($settings as $k => $v)
$string .= '
(\'' 
$k '\', \'' addslashes($v) . '\'),';

if ($string != '')
$result db_query("
. ($overwrite 'REPLACE' 'INSERT IGNORE') . " INTO {$db_prefix}settings
(variable, value)
VALUES" 
substr($string0, -1),__FILE__,__LINE__);
}

function 
moveDown($id)
{
global $modSettings;

$replace $id 1;
if (!isset($modSettings['enable_CP' $id '']) || !isset($modSettings['enable_CP' $replace '']))
return false;

$settings = array(
'enable_CP' $replace '' => $modSettings['enable_CP' $id],
'CP' $replace '_name' => $modSettings['CP' $id '_name'],
'CP' $replace '_desc' => $modSettings['CP' $id '_desc'],
'CP' $replace '_type' => $modSettings['CP' $id '_type'],
'CP' $replace '_post' => $modSettings['CP' $id '_post'],
'CP' $replace '_profile' => $modSettings['CP' $id '_profile'],
'CP' $replace '_bbc' => $modSettings['CP' $id '_bbc'],
'CP' $replace '_id' => $modSettings['CP' $id '_id'],
'CP' $replace '_hr' => $modSettings['CP' $id '_hr'],
'CP' $replace '_reg' => $modSettings['CP' $id '_reg'],
'CP' $replace '_edit' => $modSettings['CP' $id '_edit'],
'CP' $replace '_view' => $modSettings['CP' $id '_view'],
'enable_CP' $id '' => $modSettings['enable_CP' $replace],
'CP' $id '_name' => $modSettings['CP' $replace '_name'],
'CP' $id '_desc' => $modSettings['CP' $replace '_desc'],
'CP' $id '_type' => $modSettings['CP' $replace '_type'],
'CP' $id '_post' => $modSettings['CP' $replace '_post'],
'CP' $id '_profile' => $modSettings['CP' $replace '_profile'],
'CP' $id '_bbc' => $modSettings['CP' $replace '_bbc'],
'CP' $id '_id' => $modSettings['CP' $replace '_id'],
'CP' $id '_hr' => $modSettings['CP' $replace '_hr'],
'CP' $id '_reg' => $modSettings['CP' $replace '_reg'],
'CP' $id '_edit' => $modSettings['CP' $replace '_edit'],
'CP' $id '_view' => $modSettings['CP' $replace '_view'],
);

$i 1;
while (isset($modSettings['CP' $id '_data' $i]))
{
$settings['CP' $replace '_data' $i] = $modSettings['CP' $id '_data' $i];
$i++;
}
$i 1;
while (isset($modSettings['CP' $replace '_data' $i]))
{
$settings['CP' $id '_data' $i] = $modSettings['CP' $replace '_data' $i];
$i++;
}

addSettings($settingstrue);
}

function 
moveUp($id)
{
global $modSettings;

$replace $id 1;
if (!isset($modSettings['enable_CP' $id '']) || !isset($modSettings['enable_CP' $replace '']))
return false;

$settings = array(
'enable_CP' $replace '' => $modSettings['enable_CP' $id],
'CP' $replace '_name' => $modSettings['CP' $id '_name'],
'CP' $replace '_desc' => $modSettings['CP' $id '_desc'],
'CP' $replace '_type' => $modSettings['CP' $id '_type'],
'CP' $replace '_post' => $modSettings['CP' $id '_post'],
'CP' $replace '_profile' => $modSettings['CP' $id '_profile'],
'CP' $replace '_bbc' => $modSettings['CP' $id '_bbc'],
'CP' $replace '_id' => $modSettings['CP' $id '_id'],
'CP' $replace '_hr' => $modSettings['CP' $id '_hr'],
'CP' $replace '_reg' => $modSettings['CP' $id '_reg'],
'CP' $replace '_edit' => $modSettings['CP' $id '_edit'],
'CP' $replace '_view' => $modSettings['CP' $id '_view'],
'enable_CP' $id '' => $modSettings['enable_CP' $replace],
'CP' $id '_name' => $modSettings['CP' $replace '_name'],
'CP' $id '_desc' => $modSettings['CP' $replace '_desc'],
'CP' $id '_type' => $modSettings['CP' $replace '_type'],
'CP' $id '_post' => $modSettings['CP' $replace '_post'],
'CP' $id '_profile' => $modSettings['CP' $replace '_profile'],
'CP' $id '_bbc' => $modSettings['CP' $replace '_bbc'],
'CP' $id '_id' => $modSettings['CP' $replace '_id'],
'CP' $id '_hr' => $modSettings['CP' $replace '_hr'],
'CP' $id '_reg' => $modSettings['CP' $replace '_reg'],
'CP' $id '_edit' => $modSettings['CP' $replace '_edit'],
'CP' $id '_view' => $modSettings['CP' $replace '_view'],
);

$i 1;
while (isset($modSettings['CP' $id '_data' $i]))
{
$settings['CP' $replace '_data' $i] = $modSettings['CP' $id '_data' $i];
$i++;
}
$i 1;
while (isset($modSettings['CP' $replace '_data' $i]))
{
$settings['CP' $id '_data' $i] = $modSettings['CP' $replace '_data' $i];
$i++;
}

addSettings($settingstrue);
}

function 
deleteField($id)
{
global $modSettings;

if (!isset($modSettings['enable_CP' $id '']))
return false;

$i $id 1;
while (isset($modSettings['enable_CP' $i '']))
{
moveUp($i);
echo 'up';
$i++;
}
$i--;
$settings = array('enable_CP' $i'CP' $i '_name''CP' $i '_desc''CP' $i '_type''CP' $i '_post''CP' $i '_profile''CP' $i '_bbc''CP' $i '_id''CP' $i '_hr''CP' $i '_reg''CP' $i '_edit''CP' $i '_view',);
$n 1;
while (isset($modSettings['CP' $i '_data' $n]))
{
$settings[] = 'CP' $i '_data' $n;
$n++;
}

deleteSettings($settings);

}

function 
deleteSettings($settings)
{
global $db_prefix;

foreach ($settings as $delete)
$result db_query("DELETE FROM {$db_prefix}settings WHERE variable = '$delete' LIMIT 1"__FILE____LINE__);
}
?>


Sorry with my english, because i don't speack english
Title: Re: [Tip&trick] Vb postbit
Post by: Realinfo on January 08, 2012, 02:41:31 AM
Can it possible in 2.0.2.............. Now I have 2.0.2.............. In 1.1.16, I could do it, but not in 2.0.2
Title: Re: [Tip&trick] Vb postbit
Post by: mr.Curiosity on April 09, 2012, 03:09:00 AM
Like This...


Thank You.