Attempt to Create my First Plugin

Chrisspitz

Member
Hello.
I'm attempting to create my first plugin.
For my plugin i'm attempting to make changes to the languages\english.php file.. I'm not adding new lines or 'deffinitions' i'm just trying to change all the phrases that say site or sites to servers.

I have gone through and edited all the lines to what I want them changed to.

Currently I have the files in my plugins directory:

index.html (blank file)
info.php (contains the plugin info
languages\english.php

Inside my english.php file I know is where the issue is. First of all I have tried uploading the plugin just to see if it worked with what I did, and only the 'delete' image in the plugin manager shows up, not the install button.. Not surprised because in my english.php file i'm not "telling" it to make any changes I just defined a bunch of things that are already in the english.php file... Anyway here is my english.php file hope someone understands and can help :)

Code:
<?php

if (!defined('ATSPHP')) {
  die("This file cannot be accessed directly.");
}

// When you make a new translation, fill out the following four variables to
// get credit for you work.
$translation = 'English';
$translator_name = 'Chrisspitz';
$translator_email = 'spitzchriz@gmail.com';
$translator_url = 'http://www.rubikscraft.com/';

// Set this to the character encoding of your translation
$LNG['charset'] = "iso-8859-1";

$LNG['search_no_sites'] = "Sorry, no servers matching your criteria were found."; // 5.0
$LNG['ssi_top'] = "Top %s Servers"; // 4.0
$LNG['ssi_all'] = "All Servers"; // 4.0
$LNG['a_main_approves'] = "There are %s servers waiting to be approved."; // 5.0
$LNG['a_main_approve_edit'] = "There is 1 server edit waiting to be approved."; // 5.2.0
$LNG['a_main_approve_edits'] = "There are %s server edits waiting to be approved."; // 5.2.0
$LNG['a_man_ban_instructions'] = "To ban sites and users from your VisioList, fill out the form below.  When a member joins, the URL, email address, username, and IP address are checked.  When a server is edited, the URL and email address are checked.<br /><br />The blacklist will not affect your existing members."; // 5.2.0
$LNG['a_s_button_info'] = "Would you like to count pageviews on your members servers?";
$LNG['a_s_button_url_static'] = "If Yes - URL to the default button you want to appear on members' servers";
$LNG['a_s_button_url_rank'] = "If Yes - URL to the default button you want to appear on members' servers ( for Members without Rank on button )";
$LNG['premium_sites'] = 'Premium Servers';
$LNG['edit_delay'] = "Changes to your server's title and URL must be approved by the administrator before taking effect."; // 5.2.0
$LNG['join_header'] = "Add Server";
$LNG['join_error_title'] = "Enter a title for your server name.";
$LNG['join_approve'] = "Thank you for joining!  Your server will be listed when the admin approves it.  You will receive an email with more information when your server is approved."; // 5.2.0
$LNG['lost_pw_email'] = "To pick a new password for your server, just go to this URL:"; // 5.0
$LNG['main_menu_join'] = "Add Your Server";
$LNG['table_your_site_here'] = "Your Server Here"; // 5.2.0
$LNG['rate_error'] = "You have already rated this server.";
$LNG['stats_rate'] = "Rate and Review This Server";
$LNG['a_edit_site_is'] = "This server is"; // 4.0

?>
EDIT: Lol learned my first lesson. I tried using a str replace command and tested it with one of those.. It sort of worked, but it ended up replacing my entire english.php file with what I had put in it.. Learning a little more about the plugin manager.. I'll mess with it more in a few hours after I get home from work.
 

Basti

Administrator
Staff member
i think the issue here is that in index.php the normal language files are loaded before the plugin language files are loaded: it was never intended to overwrite existing text, but to create new text specific to the plugin.

On the upside. A admin language editor is planned for VL, which has exactly that purpose, but it may still be a few versions before that come

Let me test out a few things tomorrow ( getting late allready )
 

Basti

Administrator
Staff member
Ok i tested quick, and your original method works just fine

Plugin name -> Languages
- blank index.html
- info.php containing info
- languages folder with blank index.html and english.php
---- in english.php redefine the text as you did

Must be something else disturbing in your code
 

Chrisspitz

Member
Ah that's exciting that I made something that works, I'm at work right now so I can't experiment to see why I was having problems... I forgot to put a blank index.html in my languages folder I believe, could that be the cause? I'm going to assume so for now I'm off work in an hour then I'll go check it out.
 

Mark

Administrator
Staff member
the blank index.html file is not used at all, just to prevent directory browsing. lets see what you find when you get back :)
 

Chrisspitz

Member
Hm alright...
Well i'm messing around with it right now.
Adding a blank index.html into the languages folder didn't help like you said.

I archived my plugin and uploaded it with the plugin manager & it uploads, but then a few php errors are displayed on the screen.
I'm using this with one of my test domains, but heres the error(s):

Warning: include(plugins/SitesToServers/languages/english.php) [function.include]: failed to open stream: No such file or directory in /home/rubikscr/public_html/topmineservers.com/index.php on line 135

Warning: include(plugins/SitesToServers/languages/english.php) [function.include]: failed to open stream: No such file or directory in /home/rubikscr/public_html/topmineservers.com/index.php on line 135

Warning: include() [function.include]: Failed opening 'plugins/SitesToServers/languages/english.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/rubikscr/public_html/topmineservers.com/index.php on line 135

I then looked into the plugins directory to see what it uploaded and the plugin directory was there, I go inside it and the info file and index.html are missing, and the language folder is there... Inside the language folder the english.php and index.html there is also missing. Not sure if this is supposed to happen.

I then deleted the plugin and then manually uploaded the plugin to the plugins folder and the errors disappeared and the plugin appears in the plugins area of the admin cp.
I looked and none of the changes were made :|... There is no install image showing either only the 'delete' image option.

Must be something else disturbing in your code
I'm guessing Basti was saying something was wrong with my code before and I misunderstood him..
 

Mark

Administrator
Staff member
install icon will only show if you have database changes for your plugin, in this case you dont so you will only see the delete icon.

It sounds to me like you have some filenames or structure not quite right but without seeing it first hand its impossible to say. Compare it to the other plugins that do work fine and you should be able to spot it. Feel free to post your zip here and we can take a look for you.
 

Basti

Administrator
Staff member
Uploaded your plugin as it is without problems. Looked at join page website title. "Add your Site" changed to "Add server"

How are you uploading your plugin? Through admin?
Iam certain the problem is that your zip included a folder. That should not be. The folder is created automatical when you upload the plugin based on the name of the zip.
The Zip itself should only contain the files along with the language folder and it files.

And for readability info.php plugin name dont need to be named the same as the zip
PHP:
$pluginname = 'Sites To Servers';
is fine and better to read
 

Chrisspitz

Member
Ah I never even realized when I was archiving it it was doing that, should've checked. And good point, I changed it to "Camel Case" to match the folder name just in case.

About to check and see if it works which I know it will now thanks :D
 

Chrisspitz

Member
Wow. Strange. It still didn't work. Archived it properly this time I will attach it. I am uploaded it via the "Plugins" section of the admin control panel. The website I am running it on has a fresh install of visiolist .5 with nothing on it. I thought it could be cache, but I loaded my site through a proxy after uploading it to make 100% sure, and it still didn't change.
 

Attachments

Basti

Administrator
Staff member
Strange, can you send me the url where you test this on?
It works just fine, i tested on fresh 0.5 also, so there must be some odd behavour on your side somewhere.

Also make sure you dont look at the main menu and hoping to see it updating. That are db stored value and need to be changed in the menu manager
 

Chrisspitz

Member
topmineservers.com is my testing domain for this.
I'll make you an administrator account I guess in a minute if that help's and PM you the details. I don't - I refresh the page to check and see if it's there.

EDIT: I'm an idiot there aren't administrator accounts only a set admin password... Hm
 

Basti

Administrator
Staff member
Works just fine on your page. See the website title http://topmineservers.com/join/ here.
Code:
<title>Top Minecraft Servers | TopMineServers.com - Add Server</title>
If you click the login box at the top you will also see Add Server
 

Chrisspitz

Member
Must've been cached on both my laptop and the proxy apparently. I'm on my phone now and can see it's working, thanks. I must have missed some changed since I can still see two 'Add Your Site' links. I'll go back later tonight and check/find the one I missed.

Thanks for your help Basti & Mark - my first simple plugin, maybe I can end up being useful and making something nice lol. I think I could implement my server status thing into a plugin but that would be a lot of work. Who knows maybe ill try :eek:
 

Basti

Administrator
Staff member
No problem :) If you have trouble finding the missing one, let us know where they are located and we will help find them
 
Top