How to access a module in joomla
I have created a calendar module in Joomla. My main file is named jom_cal. Now from admin side i displayed the calendar in the left panel. Further what i want to do is - when a user clicks on a date in calendar i want to open a light box which will show a listing of some records from database into the lightbox. I have c开发者_C百科reated a lightbox we just need to pass the url of the page which we would like to be displayed in the lightbox. Now my question over here is where should i write the code to fetch the records from database and display in the lightbox as in a module i think there is only one main file with the same name a as module. Is there any way that i can create a separate file which will contain the code to display records from my db and then how can i access this file (i.e. what will be the url to access this file).
Kindly guide me with some appropriate way.
Thanks - Atul
If you want to remain within the Joomla way of doing things you will need a component to help you do this. Modules by definition (Joomla definition) are used to render/display data on page loads, so any data to be displayed must be pulled from the db or any other sources on page load. Certainly in Joomla 1.5 there is no safe url access to a module file.
Possible Solutions
- Use a helper component.
- If pulling all your data (to be displayed) from the db on page load and storing in hidden elements on the page, then displayed in light-boxes on click is feasible then do it. Personally i will not do this, for so many reasons.
Your module seems to want to do alot. A few things to clarify tho. Who/what created the database from whence you want to display records from? is it another component? if yes, then that component probably will have a menas of obtaining that data, maybe an ajax call etc.
You are trying to make a module do a component's job. A component allows you to define a type of content, as well as various methods of retrieving and displaying the content. A module is simply a way to display content in a position other than the main component area of the site. In order for this to work you will need to code a component, the module will simply be accessing some of the data controlled by the component.
http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
You might also look in the Joomla Extension Directory. I can think of several very advanced calendar extensions that would likely do what you need or at least be modified easily to meet your needs.
http://extensions.joomla.org/extensions/calendars-a-events
You should create a component like other people have answered. Once you created the records list layout, in the link to the records list page add format=raw to only show the component output and not display surrounding template html. Will also need to add view.raw.php in the root of the view directory for the record list page.
Not sure how you created the lightbox. I generally use the mootools modal box that does a ajax post to get the page contents and display in the lightbox.
精彩评论