View Full Version : Content of a module
gbrain
01-25-2006, 01:07 PM
OK back to basics.
I have recently installed vbulletin and CMPS. I have learnt to create new pages in vbulletin and now want to create a module for CMPS.
Is there a template I can use to learn how they work. I have gone throught the files already in the CMPS but cant get my head around it. (im not a dev)
to make like simple lets say I want to create a module with 3 rows of text
<?php
$htmlmodule = "<tr><td>line 1</td></tr>"
. "<tr><td>line 2</td></tr>"
. "<tr><td>line 3</td></tr>"
?>
Nothing fancy.
I create a new module and call it test. the identifier is "test_list" and point the phpfile to the above file in ./modules/testlist.php
Will this use the 'adv_portal_module_shell' template as stated in the add module page.
Is it that easy ? Or am I missing something big time.
thanks and sorry to ask such a simple question.
thanks
G.
Brian
01-25-2006, 04:47 PM
If you're just trying to add simple text like that then there's no reason to add a PHP file module. A BB code or template module would be much better.
gbrain
01-25-2006, 04:52 PM
well the end goal is to make this a module
excuse the code
<?php
$filename = "http://www.vendetta-online.com/x/guildinfo/70/";
$guild_test = file_get_contents($filename);
$activefile = "http://www.vendetta-online.com/h/active.html";
$active = file_get_contents($activefile);
$num1 = strpos($guild_test, "There are ");
$num2 = strpos($guild_test, " members" , $num1);
//echo $num1 . " to " . $num2 . "<br>";
$num_members = substr($guild_test, $num1+strlen("There are ") , 2);
for ($x=1; $x<=$num_members; $x=$x+1) {
$namestr1 = "<font class=itani>";
$namestr2 = "</font>";
$name1 = strpos($guild_test, $namestr1, $name2);
$name2 = strpos($guild_test, $namestr2, $name1);
$rankstr1 = "td><td class=guildText align=left>";
$rankstr2 = "</td>";
$rank1 = strpos($guild_test , $rankstr1 , $rank2);
$rank2 = strpos($guild_test , $rankstr2 , $rank1);
$linkstr1 = "<a href=";
$linkstr2 = "><font";
$link1 = strpos($guild_test, $linkstr1, $link2);
$link2 = strpos($guild_test, $linkstr2, $link1);
$username = substr($guild_test, $name1+strlen($namestr1), $name2-($name1+strlen($namestr1)));
$rank = substr($guild_test, $rank1+strlen($rankstr1), $rank2-($rank1+strlen($rankstr1)));
$link = substr($guild_test, $link1+strlen($linkstr1)+1, $link2-($link1+strlen($linkstr1))+1);
$useractive = strpos($active, $username);
if ($useractive != null)
{
$online = 1;
} else {
$online = 0;
}
$guild_data[$x] = array($username, $rank, $link, $online);
}
for ($x=1;$x<=count($guild_data);$x=$x+1)
{
if ($guild_data[$x][3] == 1)
{
$bgcolour="#00FF00";
} else {
$bgcolour="#FF0000";
}
?>
<tr>
<td width="5" bgcolor="<? echo $bgcolour ; ?>"> </td>
<td><? echo $guild_data[$x][0] ; ?></td>
<td><? echo $guild_data[$x][1] ; ?></td>
</tr>
<? } ?>
Brian
01-25-2006, 05:10 PM
Ahh, gotcha. :)
You may want to have a look at this page then:
http://www.vbadvanced.com/membersarea.php?do=viewusermanual&productid=4&pageid=5
Or, if you don't want to put your code into templates, just be sure to turn on the 'Clean File Output' option for that module.
gbrain
01-25-2006, 05:23 PM
ok idiot hat on.
is it just put that code into a file and then create a module pointing to that file and it will put the header and box around it.
?
Brian
01-25-2006, 05:26 PM
Not really... The variable $home["$mods[modid]"]['content'] needs to be used to "store" all of the content for the module.
gbrain
01-25-2006, 05:37 PM
ok getting there.
can you tell me what I am doing wrong here then
http://dndgamer.gbrain.co.uk/
the header is not going across the entire module
i have added
?>
<tr>
<td width="3" bgcolor="<? echo $bgcolour ; ?>"> </td>
<td><? echo $guild_data[$x][0] ; ?></td>
<td><? echo $guild_data[$x][1] ; ?></td>
</tr>
<? }
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_module_shell' ) . '";');
?>
gbrain
01-25-2006, 07:30 PM
dont worry Brian I think i understand whats going on.
thanks for pointing me in the right direction
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.