Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x
Author Message
gator81
Worker
Worker



Joined: Jun 09, 2007
Posts: 172

PostPosted: Sat Sep 22, 2012 3:08 pm Reply with quote

I am sorry to keep asking in different ways but i have been researching for the last couple weeks on information to convert a module to a true block. Not a module running in a block.
I have seen some code that could bring me close but then found that it was code from a few years ago and would not get me to where i am trying.

so far the module seems to be self supporting except for a couple of files that set it up as a module
Code:
if (!defined('INDEX_FILE')) define('INDEX_FILE', true); // Set to FALSE to hide right blocks 

if (defined('INDEX_FILE') AND INDEX_FILE === true) {
   // auto set right blocks for pre patch 3.1 compatibility
   $index = 1;
}

require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
require_once 'modules/' . $module_name . '/language.php';
gcalGetLang($module_name);


where i see as a sample of a block has this

Code:


if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}


the one defines a module and the other a block.

In the file i want to convert there are only a couple of the files that define as a module and link to the mainfile.php. It looks other then that everything else is contained. the sql routines, and other setups to view.
which in my skills i can only guess that there could be a change to a block without a complete rewrite.
I understand you can create a block to run a module but it still takes the rules of a module and not a block.

any direction or links you can show to help could get me one step closer...thank you for your endulgence.
 
View user's profile Send private message
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6795
Location: Ha Noi, Viet Nam

PostPosted: Sat Sep 22, 2012 3:42 pm Reply with quote

In a nutshell INDEX_FILE just tells the theme to load side blocks and BLOCK_FILE is a simple security measure to prevent block files from being accessed directly.

It looks to me like you are wanting to convert a modules index.php file into a block. The best way to do that is to start with the code you already posted for the block file and copy/paste in the code from the index file WITHOUT the code you posted above in your (INDEX_FILE) example.

There are some caveats of course; anything that needs to be sent to the browser will need assigning to the $content variable (instead of using ECHO) and you may need to change any CSS styling elements to compensate for the output now needing to be narrower.

You may also need to load the correct language file - if your site only uses one language, you could simply hard code the text you need.
 
View user's profile Send private message Send e-mail
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Sat Sep 22, 2012 3:44 pm Reply with quote

I only semi understand what you are trying to accomplish, but I will offer a few words on the code you posted.

Code:


if (!defined('INDEX_FILE')) define('INDEX_FILE', true); // Set to FALSE to hide right blocks
if (defined('INDEX_FILE') AND INDEX_FILE === true) {
   // auto set right blocks for pre patch 3.1 compatibility
   $index = 1;
}

require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
require_once 'modules/' . $module_name . '/language.php';
gcalGetLang($module_name);

In a block the following is meaningless and can be removed:
Code:


if (!defined('INDEX_FILE')) define('INDEX_FILE', true); // Set to FALSE to hide right blocks
if (defined('INDEX_FILE') AND INDEX_FILE === true) {
   // auto set right blocks for pre patch 3.1 compatibility
   $index = 1;
}

require_once('mainfile.php');


In a block you have to hard code the "module" name.
Code:


$module_name = 'GCalendar';
require_once NUKE_MODULES_DIR . $module_name . '/language.php';
gcalGetLang($module_name);

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
Palbin







PostPosted: Sat Sep 22, 2012 3:45 pm Reply with quote

Since I missed Guardians post you will also need to remove and reference to header.php and footer.php.
 
gator81







PostPosted: Sat Sep 22, 2012 5:40 pm Reply with quote

thank you for the quick replys so i will try to expand on this a little more.

I am trying to convert the gcalendar to work as a full fledge block so i can also post it on the home page.

the gcalendar has a library file already in the folder so would the paths need to be changed?

If i still address this as a module (direct link) will it still be under the module rules? (cannot post 2 modules on home page) I know you can put a module in a block but it seems to still take the rule of a module.

so after changing the info to run as a block wouldnt I move it to the blocks folder?

as for the css, because i am using a different theme the css right now dosnt have any settings for the gcalander. when it loads the only problem i have is the line that shows the day of the week, other then that it uses the color style for the theme. In the css for the themes that comes with RN there are settings for the gcalendar.

out of all the files there are 10 that define as a module and then most of them are directed to files that are in the gcalendar folder.

for example
Quote:
if (!defined('MODULE_FILE')) {
die('You can\'t access this file directly...');
}

require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
require_once 'modules/' . $module_name . '/language.php';
gcalGetLang($module_name);

require_once 'modules/' . $module_name . '/gcal.inc.php';
require_once 'modules/' . $module_name . '/class.combo.php';
require_once 'modules/' . $module_name . '/common.inc.php';
require_once 'modules/' . $module_name . '/gcInputFilter.php';
require_once 'modules/' . $module_name . '/printable.php';
require_once 'modules/' . $module_name . '/displayEvent.php';
require_once 'modules/' . $module_name . '/displayCatLegend.php';
require_once 'modules/' . $module_name . '/getDailyEvents.php';

i would change the define to a block and then the require_once i would change modules to blocks as all the php files are in the gcalendar folder?
I am sorry for my ignorance, this is very insightfull for my learning.
 
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1512

PostPosted: Sat Sep 22, 2012 5:59 pm Reply with quote

What you're trying just will not work.
 
View user's profile Send private message
gator81







PostPosted: Sat Sep 22, 2012 6:17 pm Reply with quote

Neralex: It may not ever work the way i want. But as of right now you just seem to motovate me to try and proove you wrong. If everyone stopped trying anytime they were told it wont work then the world wouldnt be in the level of developement that we are now.
I am sure there will be a time that I give up and accept the result. But until then I want to know that I have tried everything that I can. If for nothing else that it will help me understand other things that I am trying to finish.
There is alot of great experience here and who knows but the help I can get could make this work Smile
 
neralex







PostPosted: Sat Sep 22, 2012 6:24 pm Reply with quote

Egal was man dir schreibt, du ignorierst es entweder aus Vorsatz, weil du es nicht einsehen willst wie das CMS arbeitet oder du begreifst es wirklich nicht. Es haben nun sehr viele Leute versucht dir zu helfen aber du bist einfach beratungsresitent und egal wieviel man sich Mühe gibt dir zu helfen, du machst immer wieder einen neuen Thread auf und stellst die gleiche Frage, deren Anwort du bereits kennst.

Übersetzen darfst du dir das gern allein. Smile
 
gator81







PostPosted: Sat Sep 22, 2012 7:43 pm Reply with quote

again, you just motovate me to try harder. Also if you have noticed there have been a few comments in different forums and they have helped. you are the only one that says "it will never happen" You will be the only one that says this, most all the other post are trying to direct me so I may have the chance to get my result, or maby just to give me the oppertunity to fail. But I know I will fail trying.
So no matter what the "rule" or the method "cms" was designed. I will not quit!!! If it means that I ask for info in a different manner, different method, it will always be to help me understand. Please realize that my questions are not ment for you to understand and I am sorry you seem to take it so personally, it is as if you feel that my pursuit of this is an insult to you and it is not ment to be that way.
I realize that as the module is written with no changes cannot be run in the home with another module. This I understand, that is why i am working on what changes can be made to get it to do what I want. An you seem to say there is no changes that can be made for this to happen and I respectfully disagree with you.
 
Guardian2003







PostPosted: Sun Sep 23, 2012 12:58 am Reply with quote

Of course you can run it as a block - it is only code after all and the only real difference between a block and a module is where the output is displayed on the page.

Yes, you would have to adjust the paths to other files that are 'included' since the file you are working on is now in a different location. You would also need to change the code in any of the forms to make sure the form was processed by the correct file.
If you wanted to, you could just find in the theme.php where blocks(c) for center blocks is used and add your code directly in there so it is not governed by the block rules but is displayed as though it looks like a block.

If you are needing fucntionality that allows the user to interact with the block, it might even be better to use a standard gCalendar block and add links to the functionality you need back to the module and once whatever proces is completed, change the cGalendar module code to redirect back to the homepage - there are lots of options you could choose from.
 
neralex







PostPosted: Sun Sep 23, 2012 5:02 am Reply with quote

again for YOU gator81, your personal attacks are like a small child. *popcorn*

Besides of this, i have worked for years with the GC module and have it modified in many directions. Finally, I built myself a calendar. But this is a other story. Smile
 
andyb2
Regular
Regular



Joined: Aug 26, 2012
Posts: 60

PostPosted: Sun Sep 23, 2012 6:31 am Reply with quote

maybe worth locking this thread? Too many.... [ Only registered users can see links on this board! Get registered or login! ]
<b>gator81</b> - I think the issue is everyone trying to communicate in English when it's not their native language, "lost in translation". I think -personally speaking- it would also help is you only had one topic/ thread on the same subject/ request/ requirement as I now know of two, and trying to keep up with both is "confusing".
I've replied in the other thread with an image of what I think you maybe wanting to achieve, I'm not sure...
 
View user's profile Send private message
gator81







PostPosted: Sun Sep 23, 2012 8:07 am Reply with quote

I replied to the other thread. And as i said in the other one also, that sometimes a little different wording helps to get a responce. Instead it seems that the translation has generated hate instead of help.
so thank you for your help.
 
gator81







PostPosted: Mon Sep 24, 2012 10:57 pm Reply with quote

I will just put a link, so anyone can view the fix. All I can say is that it works and works as a block Smile

http://www.ravenphpscripts.com/modules.php?name=Forums&file=viewtopic&p=160180#160180

thanks for the help
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©