I am trying to provide 2 different add_widget_type statements to the widgets used on my site. The first will be loaded when the page owner is logged in and the other will be used when the user visits another users profile.
It seems that the widgets are being loaded before the page_owner data and/or loggedin_userid data become availible to do a comparasion.
eg. $po = 1
$uid = 1
if ($po == $uid)
add_widget_type
elseif ($po != $uid)
add_widget_type
Seems to work fine, But
$po = page_owner
$uid = get_loggedin_userid
if ($po == $uid)
add_widget_type
elseif ($po != $uid)
add_widget_type
Dose not work at all,,,,,,, So I'm thinking this is a timing issue.
Any Ideas?
Thanks for all the help
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
Where is this "switch" code and when does it get executed?
What are the IDs of page owner and logged user? Are they what you expect? Page owner is set (among other possibilities) based on request parameters like 'username' and 'owner_guid'. You may want to check their values and perhaps also $_SERVER['REQUEST_URI'].
These switch codes are in the start php of the widgets I am using.
I have defined the profile index.php to set the context for different profile types this work very well until a user trys to view another user. The Admin is able to see the widget users have selected and the users are able to see the admin's page but other user pages show up with no widgets selected.
I'm thinking that some how the context is not being pasted when a user starts browsing other users.
When does your switch code get executed? Is it in the init function of a plugin, so that it is triggered during "system init"? If so, that would be a problem. Page owner is probably not yet defined at that stage. If you print out page_owner() before your switch code, you probably will see '0'.
ok after alot of trial and error I have found my problem but I'm not sure how to fix it.
As I said before I am trying to filter widgets between user types. What I did to get this far is add an if/elseif statment to the index.php of the profile plugin just afer $username = get_input('username') which sets the context according to which profile type a user has chosen. I use profile manager to allow users to choose their profile type.
Once I had the context set in the profile plugin I edited the start.php of the widgets I am using in the add_widget_type statement's context for which profile type I wanted a user to be able to access.
This works great when a user is viewing their own page or the admin, but it seems that when a user views another users page the profile plugin trys to set the context before the page owners data is loaded causing the context to default out.
I went back to the index.php and added an else statement to my previous if / elseif which set the context to one of the 2 profile types and that type showed up, then changed it to the other and that one showed up so I now know this is my problem after all.
Is there a way to build a loop or a hook to recheck this if / elseif statement until the page owners data is loaded?
Bruce,
I'd been way too busy to respond earlier (16+hr workdays and all that...)
Try this (you do have a XAMPP test env ? ;-) -->
goto messageboard's view.php code
after //Just the loggedin user can send messages :=
if(isloggedin()){
add this code
echo "
<p>
... get context values toi print etc (you know that code lolz...)
exit();
then see what the messageboard widget thinks the context is
++ the context set by the Profile's index.php
should point you to a proper solution.
Dhruva hows it going man, I have placed an echo just after my code in the profile index.php that is displaying the context of each page visited and I can now see which context is being set for each page.
The proper context is being set for the users own page and so is the admin page but when viewing another user the context defaults back to profile which hides the widgets. If I place an else statement at the end of the if /elseif statement in the profile index.php setting the context one profile type or the other my filtering works for that profile type but not the other.
BTW I have been searching for the code you told me about earlier (funtion get context) but haven't located it yet,,,, which file it this located in,,,,, I'm starting to think this is were I shouldplace my new context code instead of were I have it set now.
Thanks for your reply man.
get_context() ?? lolz
Sorry man in an ealier discussion we had you told me the the context for the profile plug in was here:
function get_context() {
global $CONFIG;
if (isset($CONFIG->context) && !empty($CONFIG->context)) {
return $CONFIG->context;
}
if ($context = get_plugin_name(true)) {
return $context;
}
return "main";
}
I have been trying to locate this code but mostly late at night when things start to run together LOLz
I was wondering which file this code was located in.
Thanks
That's Elgg core code
In yr PlugIn just need to say -->
if ( get_context() == "???")
do this...
else
do that..............
I feel that my problems are a timing issue between the profile plugin and profile manager plugin where I willl have to figure out some way to set the page context after the profile type is set.
- Previous
- 1
- 2
- 3
- Next
You must log in to post replies.