Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Need help changing text
Old 07-22-2009, 09:30 AM Need help changing text
Webmaster Talker

Posts: 626
Trades: 0
I am using SugarCRM.

There is a situation where SugarCRM changes how it displays the subpanels in a record. In case you are not familiar I will try to explain:

In a record there are subpanels. The subpanels are built by PHP and then displayed on the page using an unordered list.

PHP Code:
<ul id="groupTabs" class="subpanelTablist">
    <
li id="All_sp_tab">
        <
a href="javascript:SUGAR.subpanelUtils.loadSubpanelGroup('All');" class="current">All</a>
    </
li>
</
ul
I would like to know if there is a way that I can programatically change the value of the anchor text? I would like to change it from the word "All" to "Contacts".

Can someone provide me with some javascript that can do this?
jim.thornton is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-22-2009, 09:35 AM Re: Need help changing text
Webmaster Talker

Posts: 626
Trades: 0
one other thing... I forgot to mention I would also like to change the id="<value>" name. I plan on using a CSS rule to hide the #All_sp_tab ID and I would like to change this value so the tab doesn't hide.
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 07-22-2009, 10:48 AM Re: Need help changing text
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
eLink = document.getElementById("All_sp_tab").firstChild;
elink.innerHTML = "Contact";
not tested but looks ok

The ID you will need to change in the CRM code somewhere, changing IDs using JS is/can be fraught with problems, as when you change it you will more than likely lose the reference to the object you are working with.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-22-2009, 11:33 PM Re: Need help changing text
Webmaster Talker

Posts: 626
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Code:
eLink = document.getElementById("All_sp_tab").firstChild;
elink.innerHTML = "Contact";
not tested but looks ok

The ID you will need to change in the CRM code somewhere, changing IDs using JS is/can be fraught with problems, as when you change it you will more than likely lose the reference to the object you are working with.
Thank you Chrishirst!

I'm sorry for the delay but I didn't get an email update that you posted.

I'm trying to avoid making the change in the SugarCRM code because I am trying to make it as upgrade-safe as possible.

If I change the ID in the code then it will break with every security patch or upgrade that I run.

I can "make-do" just changing the tab lablel but I would prefer to change the ID via javascript.

You mentioned that changing the ID via javascript will cause me to lose reference to the object. Does that mean that if I change the ID that Sugar will not "notice" the new ID because it is all generated via PHP?

If that is the case then I will just apply this javascript and change the label on the tab.
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 07-22-2009, 11:37 PM Re: Need help changing text
Webmaster Talker

Posts: 626
Trades: 0
Actually... I think, if it is possible to change the ID using javascript that I would like to try it. BECAUSE...

I plan on setting up the following CSS rule:

PHP Code:
#All_sp_tab { display: none; } 
Then, once the id is changed to somthing other than #All_sp_tab it SHOULD stay visible.

I just want to hide all the ALL tabs in SugarCRM but if there is only one tab showing, it puts the subpanel under ALL. So... I need to change the ID so that the subpanel I want won't get hidden.

Does that make sense?
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 07-23-2009, 12:45 PM Re: Need help changing text
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You can change the ID easily enough BUT any built in scripts used by Sugar will of course fail subsequently.

Using the code from above to change the ID it would need;

Code:
elink.id = "newid"
elnk = getElementById("newid")
adding to it.

However; I ould suggest that changing the tab id in Sugar will probably only be a matter of changing a variable in a config file or a database entry, as no self respecting developer should be "hard coding" such items into a script.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 07-23-2009 at 12:47 PM..
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-23-2009, 01:37 PM Re: Need help changing text
Webmaster Talker

Posts: 626
Trades: 0
The ID is definitely hard coded into a "template" file. However, I cannot change it there because I will be using the ID that is generated to hide the ALL tab. If I change it in the template file, I will not be able to hide the tab on the other pages.

Explanation:

In Sugar if there are multiple subpanels that are generated it will (based on configuration) break them up into different tabs. In addition to all of the subpanel tabs that are generated, it will add one (ALL) at the beginning that shows all the subpanels in that one tab. However, if only one subpanel is generated it skips the configured tab and shows it under the ALL tab only. (its a flawed design if you ask me. It should be the ALL tab that is skipped. But... I can't change that.

Thanks for your help.
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 07-23-2009, 09:13 PM Re: Need help changing text
Webmaster Talker

Posts: 626
Trades: 0
So if I understand correctly, the javascript would be like this:

Code:
elink = document.getElementById("All_sp_tab").firstChild;
elink.id = "newid"
to change the id?? I don't want to manipulate anything via javascript once it is changed.

Also... If I change the id to #SomethingElse and there is a pre-existing CSS rule for #SomethingElse, will it automatically pick up the CSS rule and obey it?
jim.thornton is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need help changing text
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29622 seconds with 12 queries