Jump to content
πŸ‘‰ Click here to explore Remote Jobs, Work From Home & Global News – USA πŸ‡ΊπŸ‡Έ | UK πŸ‡¬πŸ‡§ | Canada πŸ‡¨πŸ‡¦ | Pakistan πŸ‡΅πŸ‡° Γ—
🚫 Guest Access Notice Γ—

Recommended Posts

Posted

Hello dear users, not everyone know exactly how to create even a basic application in IPS 4x because of fact, that there is noΒ HOW TOΒ onΒ DevelopersΒ page yet. Most of 3x Developers have checked every each of Dev docs to create their own apps, i miss this "START HERE:" tutorial too so i'm about to tell all of You how to createΒ HelloΒ WorldΒ app, i will be explaining every each of steps so there is no "why this isn't working? what i'm doing wrong?" but let me inform you that i amΒ NOTΒ a pro coder and I can explain some things wrong but i try my best.Β ^_^

So, let's begin..

STEP 1:Β Enabling Developer mode
I'm recommending creating own apps on forums located on localhost becauseΒ of fact that the Developer Mode can mess up with your community if you do something wrong.Β ;)

You can download actualΒ Developer ToolsΒ here, after downloading the files, upload them to your parent folder of your hosting (in most cases public_html). After you've uploaded files to your www hosting, create anΒ constants.phpΒ file and putΒ this code inside:Β 

<?php

define( 'IN_DEV', TRUE );

to enable Dev Mode.

More informations here:

STEP 2:Β Creating an Application trough your Admin CP
After completing first step, you'll need to go to yourΒ ACPΒ and create application inΒ ACPΒ β†’Β SystemΒ β†’Β ApplicationsΒ using the "+ Create new" button located on top right side of page.

SHU_0DJ2pZ.thumb.png.9d269bc2a5fdca743563852b8b62f191.png

Now you can input anΒ Application Name,Β Application Directory(which is required),Β Author Name,Β Author website,Β Update Check URLΒ and set theΒ ProtectedΒ status. Let's input something like this for anΒ Hello WorldΒ app:

SHU_YLlw7J.thumb.png.fa692e9c2964e5cc92f80e1231d60520.png

After inputting some strings, let's go ahead and create app by clickingΒ SaveΒ button. Now if you look insideΒ applicationsΒ folder on your www you'll see that folder (in my case)helloworld have been created.Β Application DirectoryΒ is actually an app key too so, remember it.

STEP 3:Β Developer Center
Each of app has it's ownΒ Developer CenterΒ located inΒ ACPΒ β†’Β SystemΒ β†’Β ApplicationsΒ β†’Β Your ApplicationΒ β†’Β Dropdown menuΒ β†’Β Developer Center

SHU_aLdGoJ.thumb.png.13c3f550bc17820b24608bd6cf6748b1.png

Inside theΒ Developer CenterΒ is everything you need to build your own application, to set up your extensions, app settings, databases,Β ACPΒ Tabs etc.

SHU_8wKGAk.thumb.png.8fe5462a716a7f8d6ca1d695be252833.png

There is also an /dev/ folder located in your app folder, there you can put an custom language strings for app(/dev/lang.phpΒ dev docs), custom templates (/dev/html/front/modulekey/filename.phtmlΒ step 3 of complete example of a plugin), custom css(/dev/css/), custom email templates(/dev/email), custom js scripts(/dev/js/) and many more..

STEP 4:Β Creating modules and controllers
There are two types of modules, there areΒ adminΒ modules which are modules showed inΒ ACPΒ and there areΒ frontΒ modules which are showed on public side of forums. Because of that is just an Hello World app example, i will be showing you onlyΒ frontΒ modules, so let's begin..

Like you can see on app page (yourdomain.com/index.php?app=helloworld), there is showing an error on the font side

SHU_dLGW21.thumb.png.d50a6822155c8d60c59f935423abfe36.png

It's because there is no front module and it can be easily fixed by creating an front module(which is logical), let's create one by clicking "+ Add Module" in Developer Center (STEP 3).

SHU_nL7neG.thumb.png.d6e05bdfe1e8ebec1450f4245da4e794.png

There are only two inputs(forms),Β Module KeyΒ and againΒ Protected, so let's set this like that:

SHU_LraYAA.thumb.png.8d367d40607304e643777fd7568a7466.png

After putting some strings in inputs, clickΒ SaveΒ to create an module. Error isn't showing no more, but, there is no content either, there is justΒ 2S100/1Β error saying that requested page does not exist, that's because there is no controller created for this module, so let's create one by pressing + button onΒ helloworldΒ module.

bg.thumb.png.1e82640b6cf68ed42f8dd369e87d8fab.png

After doing that, you will see an window where you can put a filename (this is where you will be putting controller code)


SHU_P1jDRX.thumb.png.030dc95e260bd408537e37acc4ec7c17.png

Let's just call it helloworld andΒ Save it, after doing so you'll need to set it as default controller for this module so whenΒ you visit your app on front side, there will be showing default page(default controller for default module)

SHU_vLoVWD.thumb.png.c58bf919d08f625e4ac3ae4f8da06c73.png

After doing so, if you visit your app page, there will be showing an already build-in blank templateΒ 

SHU_dLGGr1.thumb.png.a90721724fde39b24b3d7fb0e007d2b3.png

Like you can se, there is already pre-configured an language stringΒ module__helloworld_helloworldΒ which is an module_modulename_controllername, this can be configured in /dev/ folder(mentioned in step three), so you need to go to your FTP and go to www/applications/helloworld/dev/ and open upΒ lang.phpΒ file, there is already something inside and it's language string for app name.

Β 

<?php

$lang = array(
	'__app_helloworld'	=> "Hello World"
);

All you need to do is add another language string and call it "module__helloworld_helloworld" it will should be like that:

Β 

<?php

$lang = array(
	'__app_helloworld'				=> "Hello World",
	'module__helloworld_helloworld'	=> "Hello World"
);

Β 

save the file and re-upload it to the /dev/ folder, after doing so, refresh page and the title will be already there!

SHU_dLGGA1.thumb.png.e9c434acb2de467d1822f2f54c8c357c.png

but still, there is nothing inside and there is no page title. So, now we will be creating an "Hello world!" inside this page and we will add "Hello World" as page title. Open up your controller file located inΒ yourdomain.com/applications/helloworld/modules/front/modulekey/controller.phpΒ there is already something inside it, it's automatically generated by Community Suite

Β 

<?php


namespace IPS\helloworld\modules\front\helloworld;

/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
	header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
	exit;
}

/**
 * helloworld
 */
class _helloworld extends \IPS\Dispatcher\Controller
{
	/**
	 * Execute
	 *
	 * @return	void
	 */
	public function execute()
	{
		
		parent::execute();
	}

	/**
	 * ...
	 *
	 * @return	void
	 */
	protected function manage()
	{
		// This is the default method if no 'do' parameter is specified
	}
	
	// Create new methods with the same name as the 'do' parameter which should execute it
}

Β 

More information aboutΒ namespacesΒ andΒ classesΒ can be foundΒ here

all you need to do is add to function execute() before parent::execute() this code:

\IPS\Output::i()->title = "Hello World";
\IPS\Output::i()->output = "Hello World!";

Β 

and it will be showing this:

SHU_Mq99Ao.thumb.png.c5ab7f8f287e1e86c5e16eaa02b6bffa.png

SHU_WL992O.png.98e7ff3aa3b8a9f75b58abd6f27db95b.png

but let's put this inside an template, for this, we will be needing an file inside /dev/html/ folder. But not exactly inside /dev/html/ folder, you'll need to create folders forΒ front/adminΒ module,Β modulekey. So it will be looking like that: /dev/html/front/helloworld/, now you need to create an .phtml file for template. Let's create one and put this inside:

Β 

<ips:template parameters="" />
<center><b>Hello World!</b></center>

Β 

now save it and upload to yourapp/dev/html/front/helloworld/ and name it helloworld.phtml. Now all you need to do is change a source a little bit, so instead of this code:

Β 

\IPS\Output::i()->title = "Hello World";
\IPS\Output::i()->output = "Hello World!";

Β 

You will have this code:

\IPS\Output::i()->title = "Hello World";
$tmp = \IPS\Theme::i()->getTemplate( 'modulename', 'appkey(Directory Name)', 'front' )->filename(parameters);
\IPS\Output::i()->output = $tmp;

Β 

after saving it you'll see this:

SHU_qLOVP3.thumb.png.dabed0afafd5a1a8946

Β 

Great News!Β You haveΒ just created an basic Hello World app with custom language strings and custom templates! Great work!Β 

Cheers.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Forum Statistics

    2.7k
    Total Topics
    10k
    Total Posts


Γ—
Γ—
  • Create New...