" I WANT NEXT GENERATION STUDENTS TO KNOW MORE,WHICH I UNKNOWN WHILE IN MY COLLEGE LIFE (வாழ்வின் புதிய அத்தியாயம் தொடக்கம்)"

get the user name using GUID

These below code help us to get the user guid,name & usename in Elgg

$user_guid = get_input(‘user_guid’);
echo $user_guid;
$user = get_user($user_guid);
echo $user->name;

// Similarly for Username like below..

echo $user->username;

get the current user GUID in Elgg

$user_guid = get_input(‘user_guid’);
echo $user_guid;

Id & Class in CSS

It is often hard to decide when to use a class versus an id for an element. Here is an easy way to think of the difference:

Use a class tag if:

  1. The style is used in various places throughout the document.
  2. The style is very general.

Use an id tag if:

  1. The style is only used once ever in the document.
  2. The style is specific to a certain area of the document.

Remember that an id can only appear once in any HTML document. Once you’ve used the id, it should not be used again on that page.

How to set radiobox checked in Elgg

In Normal HTML we can easily set radio box checked as like below..

<input type="radio" name="color" value="Red" />
<input type="radio" name="color" value="Green" checked="checked" />
<input type="radio" name="color" value="Yellow" />
But what we do if we use PHP & also especially in Elgg,
<?php echo elgg_view(‘input/radio’,array(‘internalid’ => ‘cur_radio’,’internalname’ => ’employer’, ‘options’=>array(elgg_echo(‘Current Employer’) => “current”), ‘value’ => $vars[‘entity’]->employer));?>
<?php echo elgg_view(‘input/radio’,array(‘class’ => ’employer’,’internalname’ => ’employer’, ‘options’=>array(elgg_echo(“Previous Employer”) => “previous”), ‘value’ => $vars[‘entity’]->employer));?>
To select one radio button as checked u can do as follows using javascript …
<script type=”text/javascript“>
$(document).ready(function(){
    $(“#cur_radio”).attr(“checked”,”checked”);
});
</script>
Similarly for pulldown use in javascript as follows..
         $(“#cur_radio”).attr(“disabled”,”disabled”);

Get the value of selected radio box

<input type="radio" name="color" value="Red" />
<input type="radio" name="color" value="Green" checked="checked" />
<input type="radio" name="color" value="Yellow" />
<script type="text/javascript">
    alert($('input[name=color]:checked').val())
</script>

Function in JQuery

Once i want to execute same set of codes for two common events in jquery. ie, i want to execute the code while

1 . Changes occur in dropdown

2 . While page Load.

At, that time i planned to use bind() function.But if i use bind() i should use the same code for two times.So, i planned to implement that using OR( || ) condition.But, i think it is not available..So i searched jquery.com & finally got one beautiful solution.

That Solution is Normal FUNCTION ( ) like C,C++.i call this function two times only with one set of code.That example is below..

Example:

$(“#level”).change( changes );          // call – 1
$(document).ready( changes );         // call – 2

function changes()

{

——

Set of code

——

}
Reference : http://api.jquery.com/bind/

Count Functions in elgg

Once i need the total no of blogs in archieves part..ie, under every month …at the time i used many functions.But, finally one default elgg library function helps me to get that couunt..

echo count_user_objects($page_owner->getGUID(),‘news’,$timelower,$timeupper);

it displays the number of news post in each month..