PDA

View Full Version : How to create your own custom modules (CMPS 2.0 RC2)


Pages : [1] 2

Gary Bolton
09-13-2005, 02:45 AM
CREATING NEW CUSTOM MODULES
Using this guide you can create as many new custom modules as you like to display content on your CMPS 2.0 RC2 pages, that are collapsible blocks (Modules)!


STEP ONE:
The first thing you need to do is create a new PHP file that you will be uploading to your Modules Folder. This file is used by your new "adv_portal_custom" template you create so it will be collapsible. Copy the code below into a "notpad.txt" document and re-name the bit's of code I've highlighted in RED to another name that you want your new Block (Module) to be called. For example re-name it to "custom_1" in all 3 places highlighted below. (make sure you have no spaces in your new name) like the second example shows below.


Original Example:


<?php

$collapseobj_custom = $vbcollapse['collapseobj_custom'];
$collapseimg_custom = $vbcollapse['collapseimg_custom'];

eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_custom') . '";');

?>


New Example:


<?php

$collapseobj_custom_1 = $vbcollapse['collapseobj_custom_1'];
$collapseimg_custom_1 = $vbcollapse['collapseimg_custom_1'];

eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_custom_1') . '";');

?>


Once you have made the changes to the code, use your FTP Program to view and re-name it (you use your FTP Program so you can see the ".txt" extension at the end to change when re-naming). Example here would be re-name it from custom.txt to custom_1.php



STEP TWO:
Now we need to create a new template that will make use of that PHP file we just uploaded to our Modules folder. Go into your AdminCP on your forum and choose the option to add a new template.

Here is the code for the template we use before any changes are made:


<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<thead>
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('custom')"><img id="collapseimg_custom"

src="$stylevar[imgdir_button]/collapse_tcat$collapseimg_custom.gif" alt="" border="0" /></a>
<span class="smallfont"><strong>$vba_style[portal_blockbullet] Custom Template</strong></span></td>
</tr>
</thead>
<tbody id="collapseobj_custom" style="$collapseobj_custom">
<tr>
<td class="$getbgrow">
<!-- Custom Code Start -->
YOUR CODE GOES HERE BETWEEN THESE LINES
<!-- Custom Code End -->
</td>
</tr>
</tbody>
</table>
<br />


Here is the new example to work with our PHP file above after changing the bits of code highlighted in RED.


<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<thead>
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('custom_1')"><img id="collapseimg_custom_1"

src="$stylevar[imgdir_button]/collapse_tcat$collapseimg_custom_1.gif" alt="" border="0" /></a>
<span class="smallfont"><strong>$vba_style[portal_blockbullet] Custom Template 1</strong></span></td>
</tr>
</thead>
<tbody id="collapseobj_custom_1" style="$collapseobj_custom_1">
<tr>
<td class="$getbgrow">
<!-- Custom Code Start -->
YOUR CODE GOES HERE BETWEEN THESE LINES
<!-- Custom Code End -->
</td>
</tr>
</tbody>
</table>
<br />


In this new template example you just created, we would now SAVE it as adv_portal_custom_1 to suit our custom_1.php file. So they work together.

You should now have this:
1: custom_1.php (php module file)
2: adv_portal_custom_1 (template file)




STEP THREE:
We will presume that you have already uploaded the "custom_1.php" file to your modules folder, and have created your new "adv_portal_custom_1" template.

In your CMPS settings, choose the option to Add Module. And choose PHP File as the type of module from the list. Then use these settings below.

Main Options
Module Title: Custom 1 (can be anything)
Column: Your choice (left, right, center)
Display Order: 1,2,3,4 etc (your choice)
Active: Yes
Update All Pages: Yes

PHP File Module Options
File to Include: Choose your "custom_1.php" file from the list
Identifier: custom_1 (same name as template and php file with no spaces in the name)
Templates Used: adv_portal_custom_1

Module Shell Template Options
Use Module Shell Template: No (make sure this is NOT set to yes)

These are the only changes you need to make in the settings to add the new module. You can now use this same method to add as many new modules as you wish.

cliffdover88
12-10-2005, 02:33 PM
Say this in the Step three :S

Method Not Allowed
The requested method POST is not allowed for the URL /admincp/vba_cmps_admin.php.


--------------------------------------------------------------------------------

Apache Server at Webname Port 80

Our Sponsors
 

chachu
12-14-2005, 04:07 PM
1) very helpful,
2) works like a charm :D

Although u missed one point to be mentioned, no worries ill do the needfull :D

if u follow the exact template code mentioned by Gray Bolton
the title of the module will be "Custom Module 1"

to fix tht
in the tempelate find

<span class="smallfont"><strong>$vba_style[portal_blockbullet] Custom Template</strong></span></td>


and replace the "Custom Tempalte" with wht ever u want the title to be :)

capebretoner
12-20-2005, 09:04 AM
IS this the same procedure for vBulletin 3.5.x?

Our Sponsors
 

Gary Bolton
12-20-2005, 10:45 AM
There should be no differnce between using this method to add new modules for vB 3.0 and vB 3.5.

ashketchum
03-01-2006, 01:48 PM
1) very helpful,
2) works like a charm :D

Although u missed one point to be mentioned, no worries ill do the needfull :D

if u follow the exact template code mentioned by Gray Bolton
the title of the module will be "Custom Module 1"

to fix tht
in the tempelate find

<span class="smallfont"><strong>$vba_style[portal_blockbullet] Custom Template</strong></span></td>


and replace the "Custom Tempalte" with wht ever u want the title to be :)

LOL!:D I think he did mention it by putting that piece of text in bold.

Hurricane
03-03-2006, 09:40 PM
Very Nice! This worked for me in 3.5.4

DelfShkrimm
03-25-2006, 11:30 AM
The code i want to include is php...

So it doesn't work when i include it in the template!

So, how should i do to include php code in a module?

EvilTT
04-10-2006, 09:17 AM
The code i want to include is php...

So it doesn't work when i include it in the template!

So, how should i do to include php code in a module?

god i wish someone had an answer for us haha :)

anyone?

NR Fatal
04-12-2006, 12:05 AM
The code i want to include is php...

So it doesn't work when i include it in the template!

So, how should i do to include php code in a module?


god i wish someone had an answer for us haha :)

anyone?

I think you'd add your php code into the php file you've created. The copy and paste what he has for the template code he has and then adjust it for your .php file (the filename).

plateau
04-25-2006, 05:00 AM
1.

<!-- Custom Code Start -->
YOUR CODE GOES HERE BETWEEN THESE LINES
<!-- Custom Code End -->

how to write the code in between? does it mean that we need also to write the php code by self? or can copy from else where?

I think you'd add your php code into the php file you've created. The copy and paste what he has for the template code he has and then adjust it for your .php file (the filename).

cannot get what u mean, sorry. ?

Module Shell Template Options
Use Module Shell Template: No (make sure this is NOT set to yes)

i just added a new module called Random Arcade, and if i choose NO in the module shell template options, then the layout of the vba page will be totally wrong.

what does the Module Shell do?

===

thanks in advance anyway.

sokol
05-20-2006, 09:01 PM
Module shell determines what styles and look are applied to your module, and ANY module that makes use of it.

In other words, making changes to that file will change ALL modules that use it.


-Sokol

attroll
06-02-2006, 06:30 PM
I am confused at what this does? Why would you want to create a custom module this way when you can create a custom page in CMPS or add a module that can do the same thing?

Maybe I don't understand what this does exactly.

thezman
08-19-2006, 10:12 PM
In case anyone is wondering, I followed the directions at the top of this thread exactly as written and it worked fine with 3.6 and 2.2. I even added some code and played around with it and everything worked fine.

lithlad
08-25-2006, 10:59 PM
Is it somehow possible to use php code inside the custom code block ?
when I try to enter php-code in <!-- Custom Code Start -->
YOUR CODE GOES HERE BETWEEN THESE LINES
<!-- Custom Code End -->
it doesn't get parsed at all.. (checked source, it appears there but it doesn't get parsed)

bhxtyrant
08-26-2006, 04:21 PM
Hey guys,
This thread has been very helpful to me however i have a question.I wish to make some custom border images for various existing modules such as the navigation block.I was playing around using the above info and that leaves a question.If doing this do i still need to create the first PHP file?Or will i just add the collapse code into the existing modules PHP.

Also how would i define the correct template to collapse for existing modules?Thanks for the time.

Designer
12-16-2006, 10:11 AM
Is it somehow possible to use php code inside the custom code block ?
when I try to enter php-code in
it doesn't get parsed at all.. (checked source, it appears there but it doesn't get parsed)

It wont be parsed as you appear to be writing php into a template, you'd have to put your code into the php file and then whatever data you want to use in the template would have to be stored in a variable or array that way it can be accessed by the template.

akulion
01-26-2007, 11:27 AM
thanks for this tutorial - just what I needed and works perfectly

If you could further clarify just 1 more thing...

Regarding running PHP scripts, since I have many I have made myself, simple little ones and I would like to include them in blocks as well

So could you explain how to do this if possible please?

aku

Tom_S
01-28-2007, 01:32 PM
Thanks...

iDaemon
02-01-2007, 11:36 AM
thanks this is useful

chkdg8
02-18-2007, 06:48 AM
What about for cmps 2.2.1/vb3.6.4?

jim6763nva
02-18-2007, 09:19 AM
What about for cmps 2.2.1/vb3.6.4?


Yep, Works the same in 3.6.4/ vba 2.2.1

It did for me.

Jim

carpefile
02-18-2007, 02:46 PM
Using 3.64 / VBA 2.2.1, I found a simpler way to make custom TEMPLATE modules using the Module Shell Template set to yes.

Since the shell already dictates the look and layout of the module (collapsible too) you just have to use this as your template;

<tr>
<td class="$getbgrow">
<!-- Custom Code Start -->
YOUR CODE HERE

<!-- Custom Code End -->
</td>
</tr>

The shell template does the rest.

Doing it this way, you don't have to make new php files for each instance, and you can create as many as you want (just renaming to new template).

Tom_S
02-18-2007, 08:55 PM
I don't get it. It says you have to choose a php file to use.

chkdg8
02-18-2007, 09:32 PM
Gary, can you make a tutorial for or cmps 2.2.1/vb3.6.4 users? I know it's been answered above in post #22 and #23 but I would rather have a new tutorial if you're up to it.

akulion
02-22-2007, 10:03 AM
this post should be a sticky

chkdg8
02-22-2007, 03:28 PM
I agree.

Blackhat
03-04-2007, 07:21 AM
what if you dont wanna use an external php file ?

pcurl
03-09-2007, 06:06 PM
Ok, I'm trying to make a Word Cloud - buy a word mod. I have a script I'm basically trying to hack to work as a block in CMPS.

basically I have two files..


index.php
and claim.php

when someone clicks on a word that's not already taken they'll go to
claim.php?keyword=

I want claim.php to take the place of index.php in the block.

I've already got the word cloud part working,
Now I want to implement the rest of the pages.

I'm a little new to coding myself, but I've done a lot of moding and installing.

here's my whole mod.



<?php
if ($keyword !== NULL)
{
include "wcm/claim.php";
}
else {
include "wcm/index.php";
}

$collapseobj_wcm_mod = $vbcollapse['collapseobj_wcm_mod'];
$collapseimg_wcm_mod = $vbcollapse['collapseimg_wcm_mod'];

eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_wcm_mod') . '";');




?>



What should happen, is instead of clicking on
http://www.mysite.com/cms_index.php?page=home&?keyword=Acupressure

Then claim.php the other page in the mod, will show a "Claim the keyword Acupressure" Now! And the order form, for it below.

and the word cloud won't be visible, as long as ?keyword is declared.

any help w/ regards to this would be great.

Thanks,

pcurl
03-09-2007, 06:14 PM
One more thing, would anyone know if maybe there would be a neater / easier way of possibly implementing that via ajax?

nicolerork
04-17-2007, 09:37 AM
Works great but now my the CMPS module title shows up as "Custom Template 1" and I can't figure out how to change it!

jim6763nva
05-01-2008, 10:46 AM
Anyone thought about updating this tutorial for CMPS 3.x or does it still work?

Jim

sdavis2702
05-02-2008, 11:46 PM
I don't know... it doesn't seem to be working for me with the latest verson of CMPS. It creates modules but they will NOT sit the way they are supposed to on the page. I used the User's Manual to try to figure it out.... it showed screen shots different than what I have on my screen. Am I missing something or is all this stuff outdated?

jim6763nva
05-03-2008, 12:49 AM
I tried it over the last few days and it all seems to work fine with v3.7.0 RC4 and vba 3.0.

sdavis2702
05-03-2008, 12:52 AM
Hm.... I wish I knew what the problem was. My modules get added but they change the entire layout of the page. For instance, if I make a module and try to add it to the left column, it will stack the entire left column on top of the center column on top of the right column. I don't understand why.

sdavis2702
05-03-2008, 04:15 AM
Nevermind I had to slow it down on the directions and take my sweet time. Works like a charm :) Thanks a lot!

jim6763nva
05-03-2008, 05:36 AM
Nevermind I had to slow it down on the directions and take my sweet time. Works like a charm :) Thanks a lot!

Not a problem :) I was going to suggest that if you could post a sample of the code you had so far, we could take a look and see where the issue was. I'm glad to hear you got it working. I know how frustrating it is when things don't work the way you want them to or expect. :)

Jim

ArnyVee
05-17-2008, 07:44 PM
So far, so good. Now, how do I find the code to put in the "code goes here" space. :(

I'm a newbie, so I need help with this.

jim6763nva
05-18-2008, 01:24 PM
So far, so good. Now, how do I find the code to put in the "code goes here" space. :(

I'm a newbie, so I need help with this.

Generally you would need to write it yourself or have someone do it that is familar with coding in PHP. What is it that you would like your custom module to do?

Jim

SecurityDog
06-05-2008, 08:08 AM
Hello,

i just want to make a box with the following content:


<script language="JavaScript" src="http://www.wetter.net/cgi-bin/wetter-net/websitebox.pl?TYP=102&NAME=Hannover" type="text/javascript"></script>


I create a new .php file an create a PHP file module.
But see what happen on the picture ...

jim6763nva
06-05-2008, 02:18 PM
You don't need to create a php module for this. Add the javascript to a template module, then add it to the page you want. I've attached an example. You can upload this module to your site by going to your Admincp and in the vBa CMPS menu => Download/Upload Modules. In the Upload section, browse for the module file where you saved it on your computer. Set the module as active. Choose which template this module should be applied to. Set the appropriate permissions. and click submit.

SecurityDog
06-05-2008, 05:06 PM
Ok with your sample it works great :)
In the future I will use it, to create my boxes :)

SecurityDog
06-05-2008, 05:57 PM
Hm how do you create the .module file?
If i create it, there is an error, that it isnīt a .module file, but it is xD

jim6763nva
06-08-2008, 12:11 PM
Hm how do you create the .module file?
If i create it, there is an error, that it isnīt a .module file, but it is xD

Open AdminCP
Goto vBa CMPS => Download / Upload Module
Scroll down to Download Module section
Choose ".module" as the Download File Type on the left
Select the module you want to download from the list on the right
Click Download

Yoteco
06-09-2008, 03:42 PM
Hi,

How can I add options for my module ? For example if I edit a page I can choose some options for the news module.

jim6763nva
06-09-2008, 05:08 PM
Please provide more information so that we understand what you want to do.

Thanks,
Jim

Yoteco
06-09-2008, 05:17 PM
Ok,

When I click on the link "Edit Pages" of the vBa CMPS menu. And then select a page to edit, at the bottom there's a lot of options group for each module (News, latest threads, etc.). I created a module and I want to created an option group for my module.

Here's a screenshot :

http://www.ouaismais.ch/vba.jpg

Sorry my english isn't very good, I hope you understood what I mean.

Andy R
06-11-2008, 11:47 PM
Ok, now what I would like to see is how you add custom options to your modules. Does anyone know or is there a link showing how?

Andy R
06-12-2008, 11:20 AM
Ok, now what I would like to see is how you add custom options to your modules. Does anyone know or is there a link showing how?

Ok, after much digging around I found this and I figured I would post the answer here.

To add settings to your own custom module, set Vbulletin into debug mode by opening config.php and adding this line:

$config['Misc']['debug'] = true;Now edit your module via the admincp and you will see an option on the bottom to add settings.

In your PHP script (using the example in this thread) your options will become available to you by doing this:

$cmps_options =& $vbulletin->adv_portal_opts;
$vba_options = array_merge($cmps_options['adv_portal_custom_1'], $cmps_options['adv_global']);Now whatever you named your setting, you can use in the PHP file:

$vba_options['name_of_your_setting'];(Don't forget to disable debug mode)..

Yoteco
06-12-2008, 12:04 PM
Ok, thanks !