Ning Developer Docs

Hi-

I am currently working on adding a link called "blogs" to the navigation bar. This link would direct users to the "Blogs" main section of the "profile" widget. I noticed the tutorial where you can add Javascript to insert a link after the page renders from the controller, and while this technique seemed to work mostly:
https://developer.ning.com/tutorials/Adding_a_Tab

...The issue that arose is that the "Blogs" section seems to be a subsection of "Profiles". For some reason, the navigation highlight variable or "navHighlight" page variable is set to assign the "this" class to the "membership" tab which seems to override the Javascript that assigns the "this" class to the "blogs" tab.

I also tried another technique by adding a "blogs" entry to the "navEntries" array in the XG_ModuleHelper.php instead of using the Javascript provided in the tutorial. Again, this successfully added the linked "blogs" tab to the navigation bar, but again it failed to assign the proper class "this" to the tab when the user clicked through to the "Blogs" main page. Instead the "membership" navigation tab again was highlighted.

Any suggestions on why this maybe occurring, or where I can set the "navHighlight" page variable for this particular page so that the "blogs" navigation link is properly set to "highlight" mode. An example of what I am doing can be found here:

http://smartupgradetest.ning.com/

Thanks!

Views: 5

Replies to This Discussion

kandilj: I know with the Adding a Tab JS method at least you can also use brute force JS to set the tabs back:

<script>
var currentpage = window.location;
if(currentpage == 'http://smartupgradetest.ning.com/profiles/blog/list') {
document.getElementById('xg_tab_members').className='';
document.getElementById('xg_tab_blogs').className='this';
}
</script>

That not happening for you? -E
Well, when the page intially loads yes, I could see it sets the class "this" to the "blogs" tab and it highlights for a split second then immediately the highlight shifts to "members" tab. I am assuming that means there is something overriding the js you are referring to below. This was the technique I used on the first attempt at adding the new "blogs" tab.

The solution you are seeing online is not an example of this, however, here I am utilizing the XG_MoudelHelper.php class instead and adding an array entry to navEntries array in the "getNavEntries" function. See code below:

$navEntries[] = array(xg_text('BLOGS_NAV'), 'http://smartupgradetest.ning.com/profiles/blog/list', 'blogs');

It seems like the controller resets the class after the js script has run, so I tried to solve the issue at the controller level to no avail! Any ideas? What is this "navHighlight" variable that the php in header.php page refers to? Code snippet from the header.php file in the index widget's "templates" folder:

if ($id == $this->navHighlight) {
$classes[] = 'this';
}

Is this something I can use at the page level to ensure it assigns "this" class to "blogs" tab?
Hey kandilj - the navHighlight method seems to have its roots in xg_header. In /lib/XG_TemplateHelpers.php, the function xg_header's first parameter says that it's highlight (Name of tab to be highlighted or NULL). You might want to play around with this function in particular.

A quick grep shows xg_header in the following files:

widgets/profiles/templates/blog/list.php
widgets/profiles/templates/blog/listEmpty.php
widgets/profiles/templates/blog/manageComments.php
widgets/profiles/templates/blog/managePosts.php
widgets/profiles/templates/blog/new.php
widgets/profiles/templates/blog/showProper.php

You might want to play around with the first parameter of those xg_header functions, setting it to "blog" or "blogs" or something similar to that. -Ernie
Ok sounds like a good strategy. Will let you know how it works out!
By adding the argument 'blogs' to the call to the method "xg_header" at the top of the code in widgets/profiles/templates/blogs/list.php we were able to successfully highlight the blogs tab. Thanks for your help!

The results can be found here:
http://www.smartusainsider.com/

RSS

© 2026   Created by Ning Developer Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service