4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Sun Zaza on November 10, 2007, 02:53:52 PM

Title: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 02:53:52 PM
Hi guys,

I added some text to the member_profile.html (For example: Welkom {user_name} to your profile page).
I want to show this text only to the owner of the profile page.
If someone else is visiting this member page, will get another text:
(For example: Welkom to the profile page of...)

What do I have to do to use: {if..............} text1 {endif..............} {ifnot..............} text2 {endifnot..............}

Many thanks in advance for any help,
Cruxy

Title: Re: Showing text only to the owner of the Profile page
Post by: KurtW on November 10, 2007, 03:16:48 PM
Hi,

in includes/functions.php
search:
Code: [Select]
  "is_admin" => ($user_info['user_level'] == ADMIN) ? 1 : 0,before add:
Code: [Select]
  "user_name" => $user_info['user_name'],
in templates:
Code: [Select]
{if user_loggedin} Hello {user_name}{endif user_loggedin}
or
Code: [Select]
{if user_loggedout}Please login!{endif user_loggedout}

Kurt
Title: Re: Showing text only to the owner of the Profile page
Post by: thunderstrike on November 10, 2007, 03:17:02 PM
Is good. ;)

// Step 1

In member.php file,

find:

Quote
"lang_profile_of" => $lang['profile_of'],

replace:

Code: [Select]
"lang_profile_of" => (isset($user_row[$user_table_fields['user_id']]) && $user_row[$user_table_fields['user_id']] == $user_info['user_id']) ? preg_replace("/". $site_template->start . "user_name" . $site_template->end . "/siU", format_text(trim($user_row[$user_table_fields['user_name']]), 2), $lang['profile_self_of']) : preg_replace("/" . $site_template->start . "user_name" . $site_template->end . "/siU", format_text(trim($user_row[$user_table_fields['user_name']]), 2), $lang['profile_of']),

// Step 2

In lang/english/main.php file,

find and replace:

Quote
$lang['profile_of'] = "Welcome to the profile page of <b>{user_name}</b>";

add after:

Code: [Select]
$lang['profile_self_of'] = "Welcome <b>{user_name}</b> to your profile.";

// Step 3

In templates/your_template/member_profile.html file,

find:

Quote
<td valign="top" class="head1">{lang_profile_of} {user_name}</td>

replace:

Code: [Select]
<td valign="top" class="head1">{lang_profile_of}</td>

Finish.
Title: Re: Showing text only to the owner of the Profile page
Post by: thunderstrike on November 10, 2007, 03:22:57 PM
I fix step 2. I forget for change original profile from with user name. Is fix. ;)
Title: Re: Showing text only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 03:58:29 PM
@KurtW:
I believe you misunderstood my request, but I thank you any way for your help and intention. The solution of Thunderstrike is working fine. :)

@Thunderstrike:
Your code is perfect!

Great man!  :D
Title: Re: Showing text only to the owner of the Profile page
Post by: thunderstrike on November 10, 2007, 04:18:26 PM
Quote
@Thunderstrike:
Your code is perfect!

Thank for posting.
Title: Re: Showing text only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 05:29:29 PM
Hi KurtW,

Quote
in includes/functions.php
search:
Code: [Select]
  "is_admin" => ($user_info['user_level'] == ADMIN) ? 1 : 0,before add:
Code: [Select]
  "user_name" => $user_info['user_name'],


Do you mean includes/page_header.php? :wink:
Title: Re: Showing text only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 05:39:45 PM
Hi guys,

I thought first that I will use this code to show a table only to the owner of the profile page, but I think I need something like: {if...}{endif},

For example:

Code: [Select]
{if...}
<table width="100%" border="0" cellspacing="0" cellpadding="1">
  <tr>
    <td valign="top" class="head2">
      text
    </td>
  </tr>
</table>
{endif.....}

I appreciate any help,
Cruxy
Title: Re: Showing text only to the owner of the Profile page
Post by: KurtW on November 10, 2007, 05:45:35 PM
Hi KurtW,

Quote
in includes/functions.php
search:
Code: [Select]
  "is_admin" => ($user_info['user_level'] == ADMIN) ? 1 : 0,before add:
Code: [Select]
  "user_name" => $user_info['user_name'],


Do you mean includes/page_header.php? :wink:

yes  :oops:
Title: Re: Showing text only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 05:54:37 PM
@Thunderstrike:
Quote
Is new solution:

http://www.4homepages.de/forum/index.php?topic=19374.msg104354#new

This is a really a usefull MOD (I have already an idea how to use it on my gallery), but in this mod you choose yourself which user will see the text or the table.
What I asked is ONLY the owner of the PROFILE PAGE will see the table.

That means if you are the USER1 and you are on your profile page (member_profile.html), you will be able to see the text or the table. But if someone else is on you profile, he will see only the normal profile information.

The text in the table on the (member_profile.html) is ONLY for you (NOT for other users or guest)
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 10, 2007, 06:53:46 PM
Quote
That means if you are the USER1 and you are on your profile page (member_profile.html), you will be able to see the text or the table. But if someone else is on you profile, he will see only the normal profile information.

The text in the table on the (member_profile.html) is ONLY for you (NOT for other users or guest)

Ok so first code I post in topic is right. Is do exact. ;)
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 06:58:38 PM
Of course not! How can I use your code to show a table? With tables you can not use main.php (The language file).
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 10, 2007, 07:30:30 PM
My code is this:

- If user ID info is match with user ID profile (same ID) - is welcome to user direct. If no same, is welcome original text ...
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 07:50:11 PM
You still misunderstand my request. I will explain:

On member_profile.html I made an extra table:

Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="1">
  <tr>
    <td valign="top" class="head2">
      ***some text here***
    </td>
  </tr>
</table><br /><br />

Under this table you find the normal information of member_profile.html:

Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="1">
  <tr>
    <td valign="top" class="head1">
      <table width="100%" border="0" cellpadding="4" cellspacing="0">
        <tr>
          <td valign="top" class="head1">{lang_profile_of} {user_name}</td>
          <td valign="top" class="head1" align="right"><a href="{url_show_user_images}" class="head1">{lang_show_user_images}</a></td>
        </tr>
        <tr>
          <td class="row1"><b>{lang_join_date}</b></td>
          <td class="row1">{user_join_date}</td>
        </tr>
        <tr>
          <td class="row2"><b>{lang_last_action}</b></td>
          <td class="row2">{user_last_action}</td>
        </tr>
        <tr>
          <td class="row1"><b>{lang_comments}</b></td>
          <td class="row1">{user_comments}</td>
        </tr>
        <tr>
          <td class="row2"><b>{lang_email}</b></td>
          <td class="row2">{if user_email}<a href="{user_mailform_link}">{user_email_save}</a>{endif user_email}</td>
        </tr>
        <tr>
          <td class="row1"><b>{lang_homepage}</b></td>
          <td class="row1">{if user_homepage}<a href="{user_homepage}" target="_blank">{user_homepage}</a>{endif user_homepage}</td>
        </tr>
        <tr>
          <td class="row2"><b>{lang_icq}</b></td>
          <td class="row2">{if user_icq}<a href="http://www.icq.com/people/about_me.php?uin={user_icq}" target="_blank">{user_icq}</a> (<b>{user_icq_status}</b>){endif user_icq}</td>
        </tr>
      </table>
    </td>
  </tr>
</table>


So I want to show this table only to the owner of the profile page (member_profile.html).

NOTE: I think that the new code will be almost a similar of you new tweak of today:
http://www.4homepages.de/forum/index.php?topic=19374.msg104354#new (http://www.4homepages.de/forum/index.php?topic=19374.msg104354#new) :wink:




Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 10, 2007, 08:18:39 PM
Quote
NOTE: I think that the new code will be almost a similar of you new tweak of today:
http://www.4homepages.de/forum/index.php?topic=19374.msg104354#new Wink

Yes ... if use tweak I code today ... you can for each username ... is same ?
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 10:40:32 PM
I can not use it because the tweak of today you have to typ the name of the user
Quote
{if user_loggedin_username} and {endif user_loggedin_username}. Replace username with true user name.
but what I want on the member_profile.html is:

If user ID info is match with user ID profile (same ID) = show the table:
Quote
<table width="100%" border="0" cellspacing="0" cellpadding="1">
  <tr>
    <td valign="top" class="head2">
      ***some text here***
    </td>
  </tr>
</table><br /><br />

If not: Show nothing (Hide the table).

Try please to TWEAK (change) this code:
Quote
"user_loggedin_" . $user_info['user_name'] => (isset($user_info['user_name']) && !empty(format_text(trim($user_info['user_name'])), 2) && $user_info['user_level'] >= USER) ? true : false,

I know that you want to help me and I know also that you are busy with other codes. So please take your time to read my request to understand what I want.
This time I explain it very very good! :wink:
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 10:46:53 PM
I could use the tweak of today if I can use {user_ID} in your code on the page_header.php. Something like:

if user_loggedin_{user_id}} and {endif user_loggedin_{user_id}},
but it is NOT possible. :x
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 10, 2007, 11:23:55 PM
Quote
***some text here***

// Step 1

In member.php file,

find:

Quote
"lang_profile_of" => $lang['profile_of'],

add after:

Code: [Select]
"lang_text_for_each_user" => (isset($user_row[$user_table_fields['user_id']]) && $user_row[$user_table_fields['user_id']] == $user_info['user_id']) ? preg_replace("/" . $site_template->start . "user_name"  . $site_template->end . "/siU", format_text(trim($user_row[$user_table_fields['user_id']]), 2), $lang['text_for_each_user']) : "",

// Step 2

In lang/english/main.php file,

on top ?>:

Code: [Select]
$lang['text_for_each_user'] = "This is text for <b>{user_name}</b>";

Edit text in lang.

// Step 3

In templates/your_template/member_profile.html file,

find:

Quote
***some text here***

replace:

Code: [Select]
{lang_text_for_each_user}

Finish.

Note: If have problem with tweak - please post in correct topic :!:
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 11:34:30 PM
Thanks for the code!

Why are you still talking about text and NOT about table.
I want to hide/show table, NOT A TEXT!

Not
Quote
***some text here***

I want to hide/show the hole table:
Quote
<table width="100%" border="0" cellspacing="0" cellpadding="1">
  <tr>
    <td valign="top" class="head2">
      ***some text here***
    </td>
  </tr>
</table><br /><br />


Oke, Listen: How can I use the same code to hide/show a TABLE instead of text.
Please i need to use {if...} {andif...} otherwise I can not use it with tables. :cry:
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 10, 2007, 11:38:22 PM
For table, you use: {if user_loggedin} and {endif user_loggedin} ...

Is for user level ...
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 10, 2007, 11:49:08 PM
Do you mean that I have first to use:

Quote
***some text here***

// Step 1

In member.php file,

find:

Quote
"lang_profile_of" => $lang['profile_of'],

add after:

Code: [Select]
"lang_text_for_each_user" => (isset($user_row[$user_table_fields['user_id']]) && $user_row[$user_table_fields['user_id']] == $user_info['user_id']) ? preg_replace("/" . $site_template->start . "user_name"  . $site_template->end . "/siU", format_text(trim($user_row[$user_table_fields['user_id']]), 2), $lang['text_for_each_user']) : "",

// Step 2

In lang/english/main.php file,

on top ?>:

Code: [Select]
$lang['text_for_each_user'] = "This is text for <b>{user_name}</b>";

Edit text in lang.

// Step 3

In templates/your_template/member_profile.html file,

find:

Quote
***some text here***

replace:

Code: [Select]
{lang_text_for_each_user}

Finish.

Note: If have problem with tweak - please post in correct topic :!:

en then

Quote
For table, you use: {if user_loggedin} and {endif user_loggedin}
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 10, 2007, 11:56:05 PM
If use my step 1-2-3 of code - you no need for use {if ... and {endif ... but if use tag, you need for add each user individual with tweak but if use step 1-2-3, query is check for match user ID current with profile user ID. If match, you use {lang_text_for_each_user} .

So do like this:

Code: [Select]
{if lang_text_for_each_user}{lang_text_for_each_user}{endif lang_text_for_each_user}

in member_profile.html file.

all tag register to $site_template->register_vars is match with IF and ENDIF tag. ;)
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 11, 2007, 12:38:23 AM
Hi,
I just test your code step 1-2-3, but {lang_text_for_each_user} is not showing.

There is something wrong with this code I think:
Quote
"lang_text_for_each_user" => (isset($user_row[$user_table_fields['user_id']]) && $user_row[$user_table_fields['user_id']] == $user_info['user_id']) ? preg_replace("/" . $site_template->start . "user_name"  . $site_template->end . "/siU", format_text(trim($user_row[$user_table_fields['user_id']]), 2), $lang['text_for_each_user']) : "",

Can you see what wrong here? :?
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 11, 2007, 12:51:21 AM
Replace code:

Code: [Select]
"lang_text_for_each_user" => (isset($user_row[$user_table_fields['user_id']]) && $user_row[$user_table_fields['user_id']] == $user_info['user_id']) ? preg_replace("/" . $site_template->start . "user_name"  . $site_template->end . "/siU", format_text(trim($user_row[$user_table_fields['user_id']]), 2), $lang['text_for_each_user']) : $lang['text_for_fun'],

In lang/english/main.php file,

in top ?>:

Code: [Select]
$lang['text_for_fun'] = "This is text for fun !";

Is show now :?:
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 11, 2007, 01:29:49 AM
I am still testing it. Nothing is showing, but I want first to try more tricks before going back to you and als to be sure about the result.
Later :)
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 11, 2007, 01:32:37 AM
Ok so remove IF and ENDIF of this lang in member_profile.html file.
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 11, 2007, 02:29:25 AM
No good niews  :x

I used
Code: [Select]
{lang_text_for_fun} on member_profile.html and

Code: [Select]
    "lang_text_for_each_user" => (isset($user_row[$user_table_fields['user_id']]) && $user_row[$user_table_fields['user_id']] == $user_info['user_id']) ? preg_replace("/" . $site_template->start . "user_name"  . $site_template->end . "/siU", format_text(trim($user_row[$user_table_fields['user_id']]), 2), $lang['text_for_each_user']) : $lang['text_for_fun'],

and
Code: [Select]
$lang['text_for_fun'] = "This is text for fun !"; in main.php
But nothing is showing yet
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 11, 2007, 02:31:17 AM
In member.php file,

replace this:

Code: [Select]
"lang_text_for_each_user" => (isset($user_row[$user_table_fields['user_id']]) && $user_row[$user_table_fields['user_id']] == $user_info['user_id']) ? preg_replace("/" . $site_template->start . "user_name"  . $site_template->end . "/siU", format_text(trim($user_row[$user_table_fields['user_name']]), 2), $lang['text_for_each_user']) : $lang['text_for_fun'],
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 11, 2007, 02:37:44 AM
Nope, nothing is showing yet :(
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 11, 2007, 02:39:37 AM
And you place code in showprofile action and no editprofile action in member.php file ?
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 11, 2007, 02:43:02 AM
After
Quote
"lang_profile_of" => $lang['profile_of'],
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 11, 2007, 02:47:08 AM
I no can reproduce problem ...
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 11, 2007, 02:52:15 AM
I will try it again tomorrow :wink:
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 11, 2007, 01:14:53 PM
Good news Thunderstrike :D

I get it to work.

In member.php you find twice the code
Code: [Select]
lang_profile_of
So this line was in the wrong section:
Code: [Select]
"lang_text_for_each_user" => (isset($user_row[$user_table_fields['user_id']]) && $user_row[$user_table_fields['user_id']] == $user_info['user_id']) ? preg_replace("/" . $site_template->start . "user_name"  . $site_template->end . "/siU", format_text(trim($user_row[$user_table_fields['user_id']]), 2), $lang['text_for_each_user']) : "",

I can now hide/show tables.
Thanks man!
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: thunderstrike on November 11, 2007, 01:37:49 PM
Quote
lang_profile_of

I no say for find twice ... I say add after line ...
Title: Re: Showing text and/of table only to the owner of the Profile page
Post by: Sun Zaza on November 11, 2007, 01:44:06 PM
Quote
I no say for find twice ... I say add after line ...

Yes I know, but I added the code after the first (lang_profile_of) in the section edit_profile instead of the (lang_profile_of) of the section show_profile.
My mistake :oops:

It is working now and I am satisfied.
Thank you again ThunderStrike :D