getField generating script tags

12 years 3 months ago #186872 by imarklee
getField generating script tags was created by imarklee
Hey guys,

I am from stackideas.com the developers of both EasyBlog and EasyDiscuss. We actually have some integrations with Community Builder and we are actually trying to pull the avatars from Community Builder. However, we were having some issues whenever we try to call the following API,
$user->getField( 'avatar', null, 'php', 'none', 'list' );

The following block of javascript codes somehow get's outputted and causing the AJAX calls to fail,
<script type="text/javascript" src="/<a href="http://****.org/components/com_comprofiler/js/jquery-1.5.2/jquery-1.5.2.min.js?v=5dc11eced412cdd6" ><="" script><script"="">http://****.org/components/com_comprofiler/js/jquery-1.5.2/jquery-1.5.2.min.js?v=5dc11eced412cdd6"></script><script</a> type="text/javascript"><!--
jQuery.noConflict();
--></script>
     
 
    <script type="text/javascript" src="/<a href="http://****.org/components/com_comprofiler/js/tabpane.min.js?v=5dc11eced412cdd6" ><="" script>"="">http://****.org/components/com_comprofiler/js/tabpane.min.js?v=5dc11eced412cdd6"></script></a>
     
 
    <script type="text/javascript"><!--
jQuery(document).ready(function($){
var cbshowtabsArray = new Array();
function showCBTab( sName ) {
    if ( typeof(sName) == 'string' ) {
        sName = sName.toLowerCase();
    }
    for (var i=0;i<cbshowtabsArray.length;i++) {
        for (var j=0;j<cbshowtabsArray[i][0].length;j++) {
            if (cbshowtabsArray[i][0][j] == sName) {
                eval(cbshowtabsArray[i][1]);
                return;
            }
        }
    }
}});
--></script>

The solution which I have used to fix this is to call the following method instead. Although this seems to work, it seems like in the source itself, this method will be deprecated in the future versions of Community Builder.
$user->avatarFilePath();

Any advise?

Please Log in to join the conversation.

12 years 3 months ago #186960 by beat
Replied by beat on topic Re: getField generating script tags
That's pretty much part of CB's browser-side API, although not used in standard cases for avatars, it is used by other field types.

That outputed javascript (properly into the page header) is using non-conflict mode, so unless the other javascript on the same page has bugs, it should not interfere imho ?

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

12 years 3 months ago #186979 by imarklee
Replied by imarklee on topic Re: getField generating script tags
Hello Beat,

Yeah, the problem here actually is because we're trying to do an ajax calls to retrieve the contents (including avatars from Community Builder) and the document type is not 'html'. Perhaps there should be some checks on the document type before that block of script is being generated would help?

Please Log in to join the conversation.

11 years 11 months ago #199572 by imarklee
Replied by imarklee on topic Re: getField generating script tags
Hey awesome guys,

Was just wondering if you have any insights on this as we don't really want to use the $user->avatarFilePath since it will be deprecated in the future. Is there any other way to trigger or load the user's avatar without also triggering the browser's API?

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.222 seconds

Facebook Twitter LinkedIn