How to get uID from Profile page?
Permalink
I'm making a block to go on a profile page, and need to get the uID of the profile page I'm on. Is there an easy way?
Thanks but I'm referring to building a block.
Are you sure its uID you need or is it cID?
I need the uID. It is passed to the view() via /profile/ID. The cID will always be the same.
I think the answer in this thread is what you are looking for...
http://www.concrete5.org/community/forums/customizing_c5/content-ba...
http://www.concrete5.org/community/forums/customizing_c5/content-ba...
Thank you for that. I did try the $profile object first to try to grab the uID but $profile is not already defined by my block controller. Do you know how to define it, or grab it somehow?
Digging through /concrete/core/controllers/single_pages/profile.php I see around line 24 in the on_view:
So... I would think adding this to your block controller *should* solve the problem ?!
I'm not positive about this though. To my understanding $profile should be available already in that case ?!
$profile = UserInfo::getByID($userID);
So... I would think adding this to your block controller *should* solve the problem ?!
I'm not positive about this though. To my understanding $profile should be available already in that case ?!
I need the uID, so if I had profile, I could get uID; if I had uID I could create profile, but it's a catch 22 :)
I still need to get the uID of the profile that I'm viewing. There's probably a million ways to get it, I just need one! :)
I still need to get the uID of the profile that I'm viewing. There's probably a million ways to get it, I just need one! :)
nevermind...
I didn't read through the whole thread
I didn't read through the whole thread
Profile is a single page that switches what it shows based on a uid extracted from the page url. The only way to get the uid for the currently showing profile is to extract it from the current url.
If you are on a profile page and there is no such url, then you can only be on your own profile page or editing the overall profile page, in which case you can use the current uID.
So for your block, you need to read the pages url and parse it.
Rather than mess about creating a block, you may well be able to achieve all you need using Magic Data. Magic Data includes symbols specifically for use on profile pages. http://www.concrete5.org/marketplace/addons/magic-data/...
If you are on a profile page and there is no such url, then you can only be on your own profile page or editing the overall profile page, in which case you can use the current uID.
So for your block, you need to read the pages url and parse it.
Rather than mess about creating a block, you may well be able to achieve all you need using Magic Data. Magic Data includes symbols specifically for use on profile pages. http://www.concrete5.org/marketplace/addons/magic-data/...
Thanks for the suggestion John. I had decided to grab the URL and parse the ID from there with string manipulation - not the way I had wanted to go but couldn't see another way without setting up an override of the profile.php page, and passing the $profile object (or at least the $uID) to a custom element. I always want to minimize my reliance on override files, so meh, went with this method.
Right click the username and inspect the element, it should display the UserID