Creating a very simple plugin - Part 2

CrazyCoder

Member
yes yes yes, i succeded to plug 3 others big parts of my new codes,
heheeeeee great great :

1) a big block showing categories on index, as a frame, with images, styling, ...

2) almost complete code part listing 5last members on index, totally own customized, lol,
INSTEAD of showing rankings !!! - means a visitor access to root,
or $form['a'], ['cat'] and ['method'] are empty, hes directly directed to this page.
BUT i still have an important modfification in index, i cannot plugin right now, sick, .... to be continued ...
3) a skin changer, wich will be updated to take care about categories skins ... later ...
... so much to do, hihihiiiii

so now ... really goin to rest for a while ... :)))))

PS : many new skins am drawing, i will sort them, somes will be given for free,
some others for a few buxs.
Thansk again for attention, care and patiente and help to Mark and Basti,
I know your time is precious, not to loose it with some crazy coder, hihihiiii
THANKS U !
 

CrazyCoder

Member
hi dudes :) as i cannot post in the plugins section,lol, i add this here :
about the disqu plugin, i followed your recommendation, Mark, and i change this in disqus.html :
HTML:
    var disqus_identifier = '{$disqus_user}-{$username}';
should be updated in 0.7, right ?

another point, could it be possible to import all comments in the DB ? i noticed there is an api at disqu.com to import data, would be great to add reviews to db, just in case disqu could loose our datas, just in case :)
 

CrazyCoder

Member
hi today :))))

1) so i just wanted to show you something i've done on index.

the goal is to decide wich page to show when user is on ROOT, and/or there are no form vars.

PHP:
// Require the appropriate file
if (isset($FORM['a']) && isset($action[$FORM['a']])) {
  $page_name = $FORM['a'];
  $page_name_path = $FORM['a'];
}
elseif (isset($FORM['app']) && isset($action[$FORM['app']])) {
  $page_name = $FORM['app'];
  $page_name_path = 'mod/'.$FORM['app'];   
}
// MODIFS DE ALAMANDRA ici evidemment, sinon COMMENT ? à voir ...
/**/
else {
if ($TMPL['skin_name'] == "youann03") {
if ($FORM['a'] == "" && $FORM['cat'] == "" && $FORM['method'] == "") {
  $page_name = 'last5_on_index';
  $page_name_path = 'last5_on_index';
}
else {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
}
elseif ($TMPL['skin_name'] != "youann03") {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
 
else {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
}
//// FIN  MODIFS DE ALAMANDRA ici
as you can see, i added a part called // MODIFS DE ALAMANDRA
to decide not to load rankings but last5 on index, the page i created

as the plugin manager is called BEFORE, i dont think i get another way to do it,
decide wich page to load, right ?


2) i want to list all sites, not only those active,
so i started on modify the concerned files : rankings.php, skin.php
removing the WHERE active = 1

but sems its not enough, arrghghhhh so gonna dig into files a few more :)))))

i did not found an option in admin panel, to decide,
if we want to list only active sites, or all sites, should they be active or not.
 

CrazyCoder

Member
3) still about my custom page, decide to show last5 members on index INSTEAD of rankings,
i had to modify the /sources/skin.php about the pagination :

Code:
if ($TMPL['header'] == "Last5") {
    $TMPL['multiple_pages_links'] = '';
    $TMPL['multiple_pages_p'] = '';
    $TMPL['multiple_pages_n'] = '';
}
 
//}//END CHECK IF pagination is set
maybe i could turn this to a plugin, i dont really know right NOW, oufffffffffffff
 

CrazyCoder

Member
arffff definitly, am a zero using the plugin manager, arrgghhhh
IF i just use my own $TMPL vars, its ok
BUT if i try to build my plugin the way Mark and basti do, tchiuuuuuuuuu nothing happen,
grrrrrr may you have a look at this new plugin version of my skin changer ? please :)))))

so you gonna laugh for a while ....

i guess i begin to be borrying, arfffff, but am i the only one,
wanting to create plugin, following YOUR way ? i hope not, hihihiiiii
 

Attachments

CrazyCoder

Member
you see if i just place my {$alamandra_customs_fields} on a wrapper,
if i just update it, plugin after plugin,
its ok,
but if i want to code a plugin using your way , i just fail ..... booooooooo its a pity ....
 

Mark

Administrator
Staff member
Hi Mate, we have added a new hook location into index.php for 0.7 that will help you with this (your request in post #3).

This is a required hook to show alternate front pages etc.

index.php

find:
PHP:
require_once("{$CONF['path']}/sources/{$page_name_path}.php");
add this BEFORE:
PHP:
eval (PluginManager::getPluginManager ()->pluginHooks ('include_source'));
that should do the trick :)
 

CrazyCoder

Member
arfff seems i dont understand something, so i give you this part i've done

A) if directly modify index + sources/skin its running fine
B) if i try to create a plugin for this, i just fail and fail, boooooooo

=============================

haaaa ok :))) welll,

so here after what i did, ouuuchhhhh REMEMBER plz all is running just fine, IF i modify the core,
but as its a very bad idea, i restart on adding all my new codes as plugins, so here whats i did about this Last 5 on Index ::::

1) create the last5_onindex.php

PHP:
<?php
header("Content-Type: text/html; charset=UTF-8");
// page de Last 5 Sites on Index
 
if (!defined('VISIOLIST')) {
  die("This file cannot be accessed directly.");
}
 
class last5_on_index extends base {
  function last5_on_index() {
    global $CONF, $DB, $FORM, $LNG, $TMPL;
 
    $TMPL['header'] = "Last5";
 
// Start Last 5 registered 4 youann
$result = $DB->query("SELECT sites.username, url, title, category, description, join_date FROM {$CONF['sql_prefix']}_sites sites WHERE active = 1 ORDER BY join_date DESC LIMIT 5", __FILE__, __LINE__);
 
 
while (list($username, $url, $title, $category, $description, $join_date) = $DB->fetch_array($result)) {
$url_image = $url;
$url_image = str_replace("http://", "www",$url_image);
$url_image = str_replace("/", "_",$url_image);
 
  $TMPL['last5_4youann'] .= "
    <div class=\"group site\">
<h3>{$title}</h3>
<p class=\"categories\">Catégorie : <a href=\"{$CONF['path']}/?cat={$category}\">{$category}</a></p>
<a href=\"{$CONF['path']}/index.php?a=stats&amp;u={$username}\" title=\"{$title}\"  target=\"_blank\">
<img class=\"photo\" src=\"screens/$url_image.jpg\" alt=\"{$title}\"></a>
<p class=\"site-teaser\">{$description}</p>
<br /><p class=\"site-teaser\">
<a class=\"bouton\" href=\"{$CONF['path']}/index.php?a=stats&amp;u={$username}\" target=\"_blank\">Voir les Statistiques</a>
<a class=\"bouton\" href=\"{$CONF['path']}/index.php?a=rate&amp;u={$username}\" target=\"_blank\">Voter et Commenter</a>
&nbsp;&nbsp;<a class=\"bouton\" href=\"{$url}\" target=\"_blank\">Voir le site</a>
    </p></div>";
}
// End Last 5 registered 4 youann
 
$TMPL['multiple_pages_p'] = "";
$TMPL['multiple_pages_links'] = "";
$TMPL['multiple_pages_n'] = "";
 
 
 
    $TMPL['content'] = $this->do_skin('last5_on_index');
  }
}
?>
1)-A uploaded this page to /sources/


2) add the declaration to index.php

PHP:
'last5_on_index' => 1,
3) created the html file : last5_on_index.html

HTML:
<div><h2>Les nouveaux sites</h2></div>
<div class="sous-titre">Les derniers sites inscrits</div>
<div class="stats_inline_block">{$last5_4youann}</div>
3)-A uploaded the file to my skin, wich is called : youann


4) created a plugin : called Last5onIndex, uploaded to /plugins/

there is the global_start.php in it :
PHP:
// MODIFS DE ALAMANDRA ici evidemment, sinon COMMENT ? à voir ...
 
if ($TMPL['skin_name'] == "youann") {
if ($FORM['a'] == "" && $FORM['cat'] == "" && $FORM['method'] == "") {
  $page_name = 'last5_on_index';
  $page_name_path = 'last5_on_index';
}
else {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
}
elseif ($TMPL['skin_name'] != "youann") {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
else {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
 
// FIN  MODIFS DE ALAMANDRA ici
of course i aded a info.php + an index.html empty, to this folder :)))))
and of course this is not working, arrggghhhhhhhhhhh ... like this, as a plugin



================= THE WAY IT WOKS ======================

BUT, of course, second time, if i add my plugin code, global_start directly to index,
this is running

1) modify the index.php :
PHP:
eval (PluginManager::getPluginManager ()->pluginHooks ('action_array'));
 
// Redirect old category links to new ones if clean_urls are off
if ($TMPL['old_cat_exist']) {
  $new_cat = preg_replace('/((\%26)|(\+))+/', '-', $_SERVER['REQUEST_URI']);
  $new_cat_url = 'http://'.$_SERVER['SERVER_NAME'].$new_cat;
 
  Header ("HTTP/1.1 301 Moved Permanently");
  Header ('Location: '.$new_cat_url);
}
 
// Require the appropriate file
if (isset($FORM['a']) && isset($action[$FORM['a']])) {
  $page_name = $FORM['a'];
  $page_name_path = $FORM['a'];
}
elseif (isset($FORM['app']) && isset($action[$FORM['app']])) {
  $page_name = $FORM['app'];
  $page_name_path = 'mod/'.$FORM['app']; 
}
 
/*
else{
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
*/
// MODIFS DE ALAMANDRA ici evidemment, sinon COMMENT ? à voir ...
 
elseif ($TMPL['skin_name'] == "youann") {
if ($FORM['a'] == "" && $FORM['cat'] == "" && $FORM['method'] == "") {
  $page_name = 'last5_on_index';
  $page_name_path = 'last5_on_index';
}
else {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
}
elseif ($TMPL['skin_name'] != "youann") {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
else {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
 
// FIN  MODIFS DE ALAMANDRA ici
haaaaa laaa laaaaaa code is a long long way to walkin, hihiihiiiiii
 

Mark

Administrator
Staff member
OK think I see where your going wrong, you didn't apply the hook location I gave you in my last post :)

instead of using "global_start" hook you should be using "include_source" (Dont forget to add that hook location I posted above)
 

CrazyCoder

Member
arfff FIRST thanks again for your attention :))))

so i added this new hook, but its not even reading my plugin file, look i also added another hook of my own:

PHP:
eval (PluginManager::getPluginManager ()->pluginHooks ('include_source'));
 
eval (PluginManager::getPluginManager ()->pluginHooks ('global_start_youann03'));
 
require_once("{$CONF['path']}/sources/{$page_name_path}.php");
$page = new $page_name;
as this code is NOW gonna performed as a plugin, i no more need to declare the page in index, lol,
the 'last5_on_index' => 1, because we no more call a page located on the /sources/ dir.

arffffffffff i am closed to the final result, but still something am doin wrong, arrgghhhhhh
i am closed !!!!!! once i'll have understood your plugin manager correctly, lets open the door to create hundreds of new plugins, and share with the community,
so please help me to finish this, boooooooooooooooo .....
am also working on a flash tagcloud, near to the good result too ....
BOOOOOOOOOOOOOO mummy its a nightmare :))))))))))


here after the include_source.php content :

PHP:
//echo "grrrrrrrrrrrrrrrrrrrrrrrrr";
 
/*
class last5_on_index  extends base {
  function last5_on_index() {
    global $CONF, $DB, $FORM, $LNG, $TMPL;
*/
 
    global $CONF, $DB, $FORM, $LNG, $TMPL;
 
    $TMPL['header'] = $LNG['last5_on_index'];
 
 
 
// Start Last 5 registered 4 youann
$result = $DB->query("SELECT sites.username, url, title, category, description, join_date FROM {$CONF['sql_prefix']}_sites sites WHERE active = 1 ORDER BY join_date DESC LIMIT 5", __FILE__, __LINE__);
 
 
while (list($username, $url, $title, $category, $description, $join_date) = $DB->fetch_array($result)) {
$url_image = $url;
$url_image = str_replace("http://", "www",$url_image);
$url_image = str_replace("/", "_",$url_image);
 
 
  $TMPL['last5_4youann'] .= "
    <div class=\"group site\">
    <h3>{$title}</h3>
    <p class=\"categories\">Catégorie : <a href=\"{$CONF['path']}/?cat={$category}\">{$category}</a></p>
    <a href=\"{$CONF['path']}/index.php?a=stats&amp;u={$username}\" title=\"{$title}\"  target=\"_blank\">
    <img class=\"photo\" src=\"screens/$url_image.jpg\" alt=\"{$title}\"></a>
    <p class=\"site-teaser\">{$description}</p>
    <br /><p class=\"site-teaser\">
    <a class=\"bouton\" href=\"{$CONF['path']}/index.php?a=stats&amp;u={$username}\" target=\"_blank\">Voir les Statistiques</a>
    <a class=\"bouton\" href=\"{$CONF['path']}/index.php?a=rate&amp;u={$username}\" target=\"_blank\">Voter et Commenter</a>
    &nbsp;&nbsp;<a class=\"bouton\" href=\"{$url}\" target=\"_blank\">Voir le site</a>
    </p></div>";
}
// End Last 5 registered 4 youann
 
 
echo "grr2222222222222222";     
 
    $TMPL['multiple_pages_p'] = "";
    $TMPL['multiple_pages_links'] = "";
    $TMPL['multiple_pages_n'] = "";
 
//}
//}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
// MODIFS DE ALAMANDRA ici evidemment, sinon COMMENT ? à voir ...
 
if ($TMPL['skin_name'] == "youann03") {
if ($FORM['a'] == "" && $FORM['cat'] == "" && $FORM['method'] == "") {
  $page_name = 'last5_on_index';
  $page_name_path = 'last5_on_index';
 
  }
else {
  $page_name = 'rankings';
  $page_name_path = 'rankings';
}
}
 
 
 
echo "--------<br />";
echo $FORM['a'];
echo "--------<br />";
echo $FORM['cat'];
echo "--------<br />";
echo $FORM['method'];
echo "--------<br />";
echo $TMPL['skin_name'];
echo "--------<br />";
echo $page_name;
echo "--------<br />";
echo $page_name_path;
echo "--------<br />";
// FIN  MODIFS DE ALAMANDRA ici
 
echo "--------<br />";
echo  $TMPL['last5_4youann'];
 
$TMPL['content'] = $TMPL['last5_4youann'];
 
//$TMPL['content'] .= $this->do_plugin_skin('./plugins/Last5onIndex','last5_on_index');

if i use a class : class last5_on_index extends base nothing happen
 

Attachments

CrazyCoder

Member
so finally :

REMEMBER i use cookies !!!! yeaahhhh to run : my SelectLang + my SkinChanger !
right.

So, i came back again on my first try.

1) added my last5_on_index.php page to /sources/

2) declare the page in index : 'last5_on_index' => 1,

3) totally transform my /plugins/Last5onIndex/include_source.php ::::

PHP:
// Start Last 5 registered 4 youann
 
if($_COOKIE['guest_skin'])
$TMPL['skin_name'] = $_COOKIE['guest_skin'];
 
if ($TMPL['skin_name'] == "youann03") {
if ($FORM['a'] == "" && $FORM['cat'] == "" && $FORM['method'] == "") {
  $page_name = 'last5_on_index';
  $page_name_path = 'last5_on_index';
 
  }
}
 
/* for debug mdrrrrr grrrrrr
echo "--------<br />";
echo $FORM['a'];
echo "--------<br />";
echo $FORM['cat'];
echo "--------<br />";
echo $FORM['method'];
echo "--------<br />";
echo $TMPL['skin_name'];
echo "--------<br />";
echo $page_name;
echo "--------<br />";
echo $page_name_path;
echo "--------<br />";
*/

So its amazing SIMPLE !!!!!!!!!!! F... grrrr grrrr grrrrrr

I use COOKIES !!!!!! this is WHY i cannot use $TMPL vars, they will be always EMPTY !!!

And NOT corresponding to ANYTHING, EXCEPT !!!!

Those $FORM['a'], ['cat'] and ['method'] lol & lol & rock & roll,
those vars come from FORMS !!!! so they still onload , heheheeeee
if i can tell this this way, hihihiiiiiiii

Its perfectly runing !!!!!!!!!!!!!!!!!

i can chage a skin, i can change a language AND i can decide to show up my last5_on_index.php,
INSTEAD of the rankings.php : IF am under my youann03 skin, AND if users are accessing to ROOT or to INDEX.PHP !!!!!!!!!!!!

But this should be a way to use your plugin manager on another way .... maybe :))))))))


Still i do not really get totally and really , HOW to well use your plugin manager

My final result is not a very regular one, isnt it ??? hihihiiiiii
but it works, dammed !!!!!!!!!!!!!!!!!!
 

CrazyCoder

Member
still i want to show up BOTH active and inactive sites on rankings,
because when i have 100 sites, 30 are active, 70 are inactive,
on the rankings page, the pagination shows up to me 6 pages to browse into !!!!

there is something wrong in the script OR in my mind, hihihiiiii

the script is supposed to list ONLY active sites, right ?

but on the rankings page, i got 6 pages on the pagination div, so it means the script is counting ALL Sites
and of course when browsing throught pages, lol, its only showing active sites, so am with 4 and half pagination pages empty ... but i got 100 sites !!!!

SO, gonna investigate :

A) i want to show up all sites, active or not, i dont care.
B) would be great to add some label : ACTIVE SITES LISTING + NON ACTIVE SITES LISTING

So i think am gonna redone all functions parts about this stuff :

put active sites on an array, and inactive ones on another,
and once on rankings page add some break :

hey people , : <label>THIS is the active sites listing !</label>
hey people , : <label>THIS is the non active sites listing !</label>


dats it, right ?
 

Basti

Administrator
Staff member
I dont get you sorry, why would want to list inactive sites?
Makes no sense, just make every member active and the problem is gone

About the pagination, it does only count active sites. You sure you didnt removed the active = 1 from the queries? i recall you mentioned that you removed that from queries everywhere
 

CrazyCoder

Member
yep i removed it on a try, but it was going to nothing, so i reput the original request.
it is possible i made a mistake on a script part, so,
i restarted on a fresh install, anyway i had to, because about what you said for updates,
its much much better to plugin all my new codes.
so right now i only got one member registered, me ! hihiiii.

gonna import the db from my aardwark, wich will give me 100 sites.
so will restest the pagination.
of couse my aardwark top site db export, i make it compatible with the vl one db,
so there are no mismatches fields on tables.

the only field missing is the owner one from VL_sites.
this perhaps could cause my bug, i mean pagination showing 6 pages,
when its listing only 30 sites, those actives.
i'll try and report :)

i only want to list all sites, active or not, because several times this makes some inactives sites, to reactive,
and/or this increase seo :) well at least i do think so
 

CrazyCoder

Member
as i converted all on utf-8, but i dont think utf_8 could be the reason, of any disfuntions of the original script.
all tables are on utf-8, all files + including the utf-8 header needed, + the set names to utf-8 on db connection.
of course all charset to utf-8 on any file ....
 

Basti

Administrator
Staff member
1. make a db
2. import aardvark backup
3. Upload vl files
4. run installer, this will convert the db
 

CrazyCoder

Member
arfff lol yesss i should thought about this way, hihiiiiiiii :) thanks basti ;)

but as it is a test site, AND more than this, i already have converted all the DB into utf-8,
i'll keep with this new db, and add some sites using the site form, just for tests.

wooo i found another important point, when dealing with cookies : the admin panel !!! lol,
and his skin : admin !
so i added a new condition to my skinchanger :

PHP:
if($FORM['a'] == 'admin')
setcookie("guest_skin", 'admin', time()+360000);
ouff ouffff if not, never admin will load his skin, hhihiiiii
its so so great and funny to improve a few my knowledge of VL,
haaaa haaa my buddies told me, am just a mad guy, having fun on coding, hihiiiiiiii
for most of them, just even thinking on coding one single line, always turns on a real endless nightmare ...
but for us its a great game, isnt it ?
well gonna destroy some cars at Need For Speed World .... just relax time :)))))))
 

CrazyCoder

Member
Oops admin needs to logout, sometimes, hihihiiii so added this also to skinchanger :

PHP:
if($FORM['a'] == 'admin' && $FORM['b'] == 'logout')
setcookie("guest_skin", 'parabola', time()+360000);
lol :)
 
Top