Jump to content

New coding style?


ChrisTERiS

Recommended Posts

Hello,

 

Back to 2007, so 10 full years ago, I have coded a Forum script for ver. 4x (?? maybe 3x). Today I decided to try it with version 7. Surprised, but at least admincp works fine. But in clientarea, I'm not getting any content in the page. As I'm not getting errors means that PHP code works, so the problem must be changes to templating system.

 

The structure of my PHP code was;

$pagetitle = '.....';
$pageicon = '.....';
$breadcrumbnav = '<a href="index.php">'.$_LANG['globalsystemname'].'</a> » <a href="forum.php">'.$_LANG['forum_forum'].'</a> » '.$mynavbar;
initialiseClientArea($pagetitle,$pageicon,$breadcrumbnav);
........PHP code here.............
// Prepare Smarty Variables
$smartyvalues["id"] = 0;
......All other variables here on the same format........
// Define the template filename to be used without the .tpl extension
$templatefile = 'forumaddthread';
outputClientArea($templatefile);

 

Is this syntax still correct? Most probably not, that's why I can't see anything in the page. Anyone can guide me on what I'm doing wrong?

 

Thank you

Edited by ChrisTERiS
Link to comment
Share on other sites

You have to use the new WHMCS\ClientArea class now. See this:

 

https://developers.whmcs.com/advanced/creating-pages/

 

Thank you for your prompt attention. Really appreciated !

 

You're right. I've found this page yesterday night but seems that today I was looking for it in wrong place. I was in https://developers.whmcs.com/modules/ and didn't noticed the "Advanced" link.

 

In any case. Something that I didn't understood well. What is the meaning of "Creating your own client area pages should orindarily be done by creating an Addon Module with client area output.". There are 2 ways to create a page?

 

Thank you

Mary

Link to comment
Share on other sites

https://github.com/WHMCS/sample-addon-module

 

May be of some assistance.

 

Thank you. Have seen that example before but I think that is mostly (if not "only") for modules using admin area. For example the /lang directory. The file english.php contains variables like:

$_ADDONLANG['variable_name'] = "Translated language string.";

That's correct syntax but only for phrases in admin area. For client area the phrases must be like

$_LANG['variable_name'] = "Translated language string.";

So what todo? Tested by combining both prefixes and didn't worked. So I need to use separate language file. What naming? etc etc. Finally I used my old structure for client area files, having all in a separate directory. So the user when will uninstall the mod will be easy to remove that directory.

Link to comment
Share on other sites

Hello,

 

Can someone guide me on how I can include phrases available in client area pages?

 

According to this article https://github.com/WHMCS/sample-addon-module I must add an english.php file in addon module /lang directory.

 

The problem is that those phrases are like:

$_ADDONLANG['variable_name'] = "Translated language string.";

while the clientarea phrases are like:

$_LANG['variable_name'] = "Translated language string.";

 

I tried to combine both styles in one file but does not works. Any idea on how I can add phrases to client area lang file without Copy and Paste?

 

Thank you

Link to comment
Share on other sites

if you're creating individual client area pages (https://developers.whmcs.com/advanced/creating-pages/), then i'd use Language Overrides.

 

if you're using an addon module, then you'd use $_addonlang

 

hmmm......... I think that I'm a bit confused. Working for years for vBulletin maybe I've messed some meanings. For me "module" is a script which adds extra functionalities to both Admincp and Public Area.

 

Let's try to use a real example. Here is my link: https://www.cmsbulletin.com/whmcs/forum.php

 

Is a forun module (?) having pages in both Admin panel and Public (Client area). I've a language file in addons/forum/lang with phrases for admin area. They work fine. For client area I just have a .txt file with phrases asking the user to copy and paste them in his language file. Works but is not professional and for sure frustated way especially in updates with new phrases.

 

I tried to include this file with normal "include" and works fine. But if you see carefully the link above it "destroy" WHMCS phrases. See at Login and Cart on the top. There are no phrases.

 

What I can do for it?

Link to comment
Share on other sites

Is a forun module (?) having pages in both Admin panel and Public (Client area). I've a language file in addons/forum/lang with phrases for admin area. They work fine. For client area I just have a .txt file with phrases asking the user to copy and paste them in his language file. Works but is not professional and for sure frustrated way especially in updates with new phrases.

as an aside, WHMCS users shouldn't edit their language files directly (as they'll get overwritten by WHMCS during an update - they'd need to add custom strings using Language Overrides.

 

however, as this is a module, that should be irrelevant - though there'd be nothing to stop you asking clients to use overrides.

 

I tried to include this file with normal "include" and works fine. But if you see carefully the link above it "destroy" WHMCS phrases. See at Login and Cart on the top. There are no phrases.

What I can do for it?

well that's definitely not the way to do it - i've PM'd you with an idea...

Link to comment
Share on other sites

One of the things I do with multiple addons, and I find works is add specifics in overrides/english.php .. For example

//updated English Language file. Only need the files necessary in here, no need to overwrite everything at once now.
//set the directory of the current file
$dir = dirname(__FILE__);
//set my lang directory
$gurudir = "$dir/gurus";
if (file_exists("$gurudir/english_gurus.php"));
{
require_once("$gurudir/english_gurus.php");
}
add more files below

 

This works for me, just like throwing everything in overrides/lang.php

 

Of course, you'll have to tweak that a bit to your own liking, but the point is that it doesn't have to be all in one file. Maintaining a few addons, I found this to be the best approach (for me)

Link to comment
Share on other sites

One of the things I do with multiple addons, and I find works is add specifics in overrides/english.php .. For example

//updated English Language file. Only need the files necessary in here, no need to overwrite everything at once now.
//set the directory of the current file
$dir = dirname(__FILE__);
//set my lang directory
$gurudir = "$dir/gurus";
if (file_exists("$gurudir/english_gurus.php"));
{
require_once("$gurudir/english_gurus.php");
}
add more files below

 

This works for me, just like throwing everything in overrides/lang.php

 

Of course, you'll have to tweak that a bit to your own liking, but the point is that it doesn't have to be all in one file. Maintaining a few addons, I found this to be the best approach (for me)

 

Thank you. Finally I used something similar. I created an english.php file in my mod /lang directory and instead to use $_LANG variables I used $MY_LANG variables. Then I included this file in my mod. Works fine without to loose any WHMCS phrase but the dark point is that I can have only one language active. Not so important.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated