Support Forums - Classified Ads Script Osclass
Osclass theme support => Free themes => Patricia Osclass Responsive Theme => Topic started by: BabyDunk 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 <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
-
@aweegander
Please check osclass docs before using some function:
https://doc.osclass.org/HItems.php (https://doc.osclass.org/HItems.php)
You should use function:
osc_item_contact_name(); //Gets contact name of current item
-
Good morning Frosticek, i hope your well :)
this function just returns users real name
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.
-
@aweegander
As far as I know, username is not used in osclass and usually is same as user id.
-
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
-
@aweegander
I think there is different usage of this field...
-
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
-
@aweegander
Yes it is possible.
$user = User::newInstance()->findByPrimaryKey( $user_id );
echo $user['s_username'];
-
Hi Forsticek
i am trying to use want you sent in your last message but not correctly .
<?php
function osc_username_now(){
$user = User::newInstance()->findByPrimaryKey( $user_id );
}
osc_username_now();
echo $user['s_username'];
?>
then call it like this
<?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
-
@aweegander
You are missing argument in function, or relation to osclass function try this:
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;
}
}
-
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 ;)
-
Worked 100% for the printpdf also :D
Happy Bunny :D
-
@aweegander
Perfect ;)
-
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
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
-
@aweegander
You cannot define same function twice. You should define it in 1 file only, i.e. functions.php