get site typename?

Discuss and get help with plugins. Share your ideas for future SiT! features.

get site typename?

Postby skyrack_technology » Mon Mar 12, 2012 11:13 am

Hello - Can anyone help me with the function I should extend / create for a query to get the typename for a site from a session contact Id?
Its obviously from the sitetype table ....?

Thanks
skyrack_technology
SiT! Regular
SiT! Regular
 
Posts: 30
Joined: Tue Nov 16, 2010 4:57 pm

Re: get site typename?

Postby Tomse » Mon Mar 12, 2012 5:02 pm

hi there :-)

there is a generic function to return a single cell based on an ID

lookup on
http://sitracker.org/doxygen/3x/

function name is: db_read_column

this might help you.

cheers
Tomse
Carsten Jensen, da-DK Translator Supporting Windows & Linux/FreeBSD installations, partial SiT developer / hacker / graphician
Live chat/support on IRC in channel #sit on freenode.net
User avatar
Tomse
SiT! Developer
SiT! Developer
 
Posts: 950
Joined: Fri Feb 20, 2009 10:51 am
Location: Somewhere near Copenhagen Denmark

Re: get site typename?

Postby skyrack_technology » Thu Mar 15, 2012 3:15 pm

Hi Thomse - as ever, appreciate your tips!

I tried this, but I should have said this is for a form for a portal logged in user, and I'm guessing that the session doesnt know about siteid, only contactid?
So, doing:

Code: Select all
echo db_read_column('typename', $GLOBALS['dbSitetypes'], $id);


Just returns nothing ....???
skyrack_technology
SiT! Regular
SiT! Regular
 
Posts: 30
Joined: Tue Nov 16, 2010 4:57 pm

Re: get site typename?

Postby Tomse » Thu Mar 15, 2012 4:34 pm

skyrack_technology wrote:Hi Thomse - as ever, appreciate your tips!

I tried this, but I should have said this is for a form for a portal logged in user, and I'm guessing that the session doesnt know about siteid, only contactid?
So, doing:

Code: Select all
echo db_read_column('typename', $GLOBALS['dbSitetypes'], $id);


Just returns nothing ....???



the $id should be the id of the table afair sitetypes have 3 default (1 = unclassified, 2 = commercial and 3 = Acedemic)
so doing:
Code: Select all

function get_sitetypes($id)
{
    // hardcode ID = 3 for this example
    $id = 3;

    global $dbSiteTypes;   
    return db_read_column('typename', $dbSiteTypes, $id);
}

will return "Acedemic"

I think your error here is the lack of capital T in sitetypes.

you can find the correct naming in lib/tablenames.inc.php


cheers
Tomse
Carsten Jensen, da-DK Translator Supporting Windows & Linux/FreeBSD installations, partial SiT developer / hacker / graphician
Live chat/support on IRC in channel #sit on freenode.net
User avatar
Tomse
SiT! Developer
SiT! Developer
 
Posts: 950
Joined: Fri Feb 20, 2009 10:51 am
Location: Somewhere near Copenhagen Denmark


Return to Plugins & Extending SiT!

Who is online

Users browsing this forum: No registered users and 1 guest

cron