This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

BabyDunk

  • ****
  • 161 posts
change displayed name on search_list.php
« on: June 16, 2016, 12:26:46 AM »
hello frosticek  :)

i dont know if i have asked you this before.  but is their a simple way of changing the displayed name on search_list.php to display username .

i have tried this
Code: [Select]
<a href="<?php echo osc_user_public_profile_url(osc_item_user_id()); ?>"><?php echo osc_user_username(); ?></a> with changing the echo to the username helper . but it doesnt work, not like it does for item.php. works 100% there.


its abit pointless trying to hide publisher name on all other parts to the sites and not this .


thanks for the help/advice
Chris
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: change displayed name on search_list.php
« Reply #1 on: June 16, 2016, 08:57:31 AM »
@aweegander
Please check osclass docs before using some function:
https://doc.osclass.org/HItems.php

You should use function:
Code: [Select]
osc_item_contact_name();  //Gets contact name of current item
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: change displayed name on search_list.php
« Reply #2 on: June 16, 2016, 12:08:22 PM »
Good morning Frosticek, i hope your well :)

this function just returns users real name
Code: [Select]
osc_item_contact_name();  //Gets contact name of current item
is their no way to echo the username. for search_list.php

is this an osclass issue ?
if it is do you not think its pointless that osclass has incorporated username's into the platform but yet cant be called on all the places where the username function is needed.
« Last Edit: June 16, 2016, 12:09:53 PM by aweegander »
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: change displayed name on search_list.php
« Reply #3 on: June 16, 2016, 12:28:37 PM »
@aweegander
As far as I know, username is not used in osclass and usually is same as user id.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: change displayed name on search_list.php
« Reply #4 on: June 16, 2016, 12:43:41 PM »
Yes that would be correct,you would change the user id to username and this is promoted by osclass. just have to check the default theme bender. in the account settings . change username option.  its abit silly not being able to use this function globally.

can it be done. is my question? lol
if you need paid for such a thing. i dont mind i would gladly pay to get to have username displayed :)

if it cant be done . the only thing would be to remove the code that displays "published by" on the search_list.php

All The Best
Chris
« Last Edit: June 16, 2016, 02:03:40 PM by aweegander »
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: change displayed name on search_list.php
« Reply #5 on: June 16, 2016, 12:47:29 PM »
@aweegander
I think there is different usage of this field...
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: change displayed name on search_list.php
« Reply #6 on: June 16, 2016, 02:12:13 PM »
lol @ Frosticek

you still havent answer the question.

can you make username display on search_list.php?

is it even possible ?


if you say its not possible i will trust your word and forget about chasing this.


Many thanks
Chris
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: change displayed name on search_list.php
« Reply #7 on: June 16, 2016, 02:13:58 PM »
@aweegander
Yes it is possible.

Code: [Select]
$user = User::newInstance()->findByPrimaryKey( $user_id );
echo $user['s_username'];
« Last Edit: June 16, 2016, 02:15:33 PM by frosticek »
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: change displayed name on search_list.php
« Reply #8 on: June 20, 2016, 06:52:52 AM »
Hi Forsticek

i am trying to use want you sent in your last message but not correctly .

Code: [Select]
<?php
function osc_username_now(){
$user User::newInstance()->findByPrimaryKey$user_id );
}

osc_username_now();
    echo 
$user['s_username'];
?>


then call it like this
Code: [Select]
         
            <?php if(osc_item_user_id() <> 0) {; ?>
            <a href="<?php echo osc_user_public_profile_url(osc_item_user_id()); ?>"><?php echo osc_username_now(); 


am i any way close?  lol
i can sort of read through the code and understand it a little. $user is equal to user new instance  which is greater than findbyprimarykey of user_id

i think thats how that reads lol

still trying to learn how it all goes together.

just looking some pointers
thanks
Chris
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

Marked as best answer by frosticek on June 20, 2016, 09:14:42 AM
*

MB Themes

Re: change displayed name on search_list.php
« Reply #9 on: June 20, 2016, 07:45:25 AM »
@aweegander
You are missing argument in function, or relation to osclass function try this:
Code: [Select]
function osc_username_now(){
  if( osc_item_user_id() <> 0 && osc_item_user_id() <> '') {
    $user = User::newInstance()->findByPrimaryKey( osc_item_user_id() );
    return $user['s_username'];
  } else {
    return false;
  }
}
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: change displayed name on search_list.php
« Reply #10 on: June 20, 2016, 07:59:56 AM »
Good Morning Frosticek :D

yes that works 100% thank you.

i will study that an try to understand it  :D

i just have one more place that needs the username hide (printpdf) and i think that function might just do the job there also


thanks again
Chris ;)
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

BabyDunk

  • ****
  • 161 posts
Re: change displayed name on search_list.php
« Reply #11 on: June 20, 2016, 08:16:47 AM »
Worked 100% for the printpdf also :D


Happy Bunny :D
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: change displayed name on search_list.php
« Reply #12 on: June 20, 2016, 09:14:52 AM »
@aweegander
Perfect ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: change displayed name on search_list.php
« Reply #13 on: June 21, 2016, 12:15:19 AM »
Hi

i had a little bit of trouble. the function works 100% but i was placing the function in the patricia/search_list.php  andto have username displayed in the printpdf i was placing the function also in printpdf/index.php  :(

 i didnt realise i had a problem until i check the search list page and seen it was broke.

i now know, you cant have the same function running in 2 seperate places   :-\ lol  error " Cannot redeclare "

so i placed the function in the patricia/functions.php

deleted all other occurrences

then i had to place this inside /printpdf/template.php
Code: [Select]
require_once('../../themes/patricia/functions.php');
both search list and printpdf are now working with no errors :D

i am doing some learning this weather  lol

Cheers
Chris
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: change displayed name on search_list.php
« Reply #14 on: June 21, 2016, 07:53:38 AM »
@aweegander
You cannot define same function twice. You should define it in 1 file only, i.e. functions.php
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots