I'm migrating my blog from wordpress to datalife engine. For what i figured it out by searching, is writen in smarty php... I never worked with it before and i want to query the database to implement something on the theme... But i can't write it on the tpl files...
What i want to know is, where are functions like {rating}, {content} or [related-news] declared...
i want to query the database, but for what i know, i can't do it on the tpl files direcly.
And i can't find any info where they are because all the readme files of datalife are in russian. Can someone help me to figure out how is this structure done?
Datalife Engine use the module files in folder /engine/modules/ to define which .tpl files to use for which function, so there is no single file that declare all tpl files, you have to check which module or which function you want to edit, in your case it seems like you are looking for full page of content which in DLE called "fullstory" the module that handle this module is engine/modules/show.full.php and the theme file to use for this module are fullstory.tpl to dispaly the rest of fullstory, addcomment.tpl for add comment form and relatednews.tpl to display related news, about {rating} there are at least 3 modules use this tag which are show.short.php, show.custom.php and show.full.php, however the DLE structure is each module use its own tpl file to display as {content}, I think if you go to dlestarter.com you can get all answer you need from them, I think they are not so advanced team but they do speak English so they can help you more effectively to any questions you may have...good luck!
Datalife Engine does not use smarty template engine!.
It has it's on custom engine.
The Flow of the cms its simple, every article has a short story and optionally a full story.
In the template folder you have a bunch of tpl files with build up the final page.
main.tpl beeing the file called for every page you display.
Now typically once you call the front page the main.tpl along with shortstory.tpl are called along with other blocks for the front page.
the shortstory.tpl is build by the /engine/modules/show.short.php file witch will call the db for the data or memcached if enabled and the data was cached replace the the engin tags with the necessary data like {title} and many others.
You should really look at the documentation to undestand witch tags are found in witch section.
One important think to note is that you cannot add php in the tpl files at least not out of the box but you can include files with php in them.
I recommend heading over to dlestarter.com they are a good reference for documentation in English and pretty much the only once as well. They also have a forum where i look into sometimes.
Related
I need to add this code to Joomla please
$(".item-204").append('<ul class="nav-child unstyled small"><li class="item-205"><a href="index.php?option=com_content&view=article&id=9" >رؤيتنا</a></li>');
what is the best way?
One way to do this would be to use Regular Labs ReReplacer which could be set up to replace the .item-204 code with .item-204 plus any additional code you require. I am assuming .item-204 is unique on the page.
The advantage of using this extension is that you don't have to find or update the core code. Updating core code is often considered bad practice as any future template or extension updates can undo your changes.
It's really just about adding this code to every page? Instead of adding another plugin so your site you can put your code in a script tag located in your templates main php file. This file is named index.php and is located here: /templates/[your template name]/index.php
If you want to do it even better, place this code in the templates JS file. Some of them have a file like /templates/[your template name]/js/custom.jswhich is a good place to add custom JS to.
I'm new to Joomla, but not a new programmer. I've written several applications in PHP that I want to include inside Joomla articles. Simple enough:
<?php include 'file.php'; ?>
The issue is that inside the PHP files I have a bunch of code gathering and creating variables that I need to POST and retrieve. I can get those POST variables inside the Article, but I can't pass them back to the included PHP file.
I've even coded the included PHP files to access the Joomla framework hoping to retrieve Joomla user id for example. This won't run inside the Article either and returns empty. However, if I run the PHP file on its own outside of the Article, I can access all POST data (obviously) and also the Joomla JFactory data. So it runs fine, until it's placed as an included file inside an Article.
The only way I've been able to pass something to the included PHP file is using $_GET url variables like this:
<?php include 'file.php?data=something'; ?>
However, this simply isn't practical as I have too many variables to pass like this. Normally, included PHP files run as part of the parent script and have access to all variables. How can I accomplish this in Joomla??
Much appreciated!
It is not recommended to include php into articles. Try instead one of these approaches:
Load your code in the index.php - file in your template: /templates/yourtemplate/index.php. This file is called every time your page is called.
Make a template override of the component where you want you external php file to be loaded. If this is in an article, you copy /components/com_content/views/article/tmpl/default.php (and possibly also other files there) to /templates/yourtemplate/html/com_content/article. Then add your include-statement here. (info) This file will be loaded each time you view a single article, but you can have further logic to only run it if (whatever)...
Use Jobin Jose's approach if you want to load you php-file inside content in an article. (info)
Some other approach writing a plugin
...or a component
I would say probably the easiest method is 2. (or 1.), but it all depends what you want to do.
Try this,
You have to create a simple module for your requirement, means what you are trying to achieve with included php file.
then place that module within the article with {loadposition module_position}
then you will get all the POST variables to that article and also suppose user_id and all other joomla Factory can be accessed bcoz its a Joomla module.
for a quick tutorial about module creation can be found here.
hope it make sense.
I resolved this using an Extension called Sourcerer
https://www.nonumber.nl/extensions/sourcerer
Variables can be passed without issue now.
Thanks for the input.
Why do not you try to create a new Joomla component and do whatever you want it it?
I am absolutely beginner in php/mysql but managed to do it with my page, following this instructions:
http://www.inmotionhosting.com/support/edu/joomla-3/create-component/helloworld
When you create this component, whatever you write in its "default.php" file, is actually a blank HTML/PHP page, with your joomla design and some other Joomla-features.
Sorry for the amateur answer and terminology :)
In the Joomla back-end, the administrator would do modifications using the GUI.
Say a module is enabled(just click the check box).
What happens in php-level?(what happens to the code?)
Some trivial assumptions I come up with are,
-commenting/uncommenting
-some code snippets are added/removed
-configuration(ex: xml) files are modified/created
Joomla itself doesn't really modify files on disk much at all. The only exceptions I can think of are:
Installing an extension (writes to '/tmp', and then the final location for the extension files)
Saving global configuration options (writes to '/configuration.php')
Caching (writes to '/cache')
All other configuration changes, entered data, etc from the admin area (and frontend) are stored in the Joomla database.
So the example given (enabling/disabling a module) doesn't edit or create any files. It only makes changes in a core database table (jos_modules, if your DB prefix is 'jos_'). Module inclusion on all pages is dynamically evaluated per page-load based on the code in your template, as #Hanny mentions.
If you read the index.php file in of the template you're using - you'll find that all the positions of the template are included in that file <jdoc include="position10" /> or something of that nature is what it will say.
Usually the templates use CSS to help determine how to 'shape' the page depending on which modules are enabled, along with 'if,then,else' statements on the php level. Read through the index.php file and you'll probably see that.
if "module10" then use "rightmodule.css" type thing - which then may hold changes to be made to certain containing div's with regards to width and that sort of thing.
No commenting/uncommenting happens, no code snippets are added and no configuration files are modified/created (at least as far as I know, and I've worked to design a component for Joomla previously). It's all if statements and tying that together with the module positions that are laid out in the templates index.php file.
This is a simplified answer, but I think it answers what you've asked.
I want to understand how to use templating system and permalinks on php websites :D !..
let me describe my self more,
1.currently i have 20 files each have its own php logic (index.php,wizard.php,search.php etc)
ALL use same class's and includes.(install.php include all the required for all class's in my project abd u require_once(install.php) in all files)
i wana remodel my website into.
Analyze URL requested ---> IDENTIFY requested page ---> GET TEMPLATE for THIS PAGE -->MODIFY header(meta) and footer(javascript) ---> add logic ---> display page :D.
can some one put me on right learning track :D !. cuz i hv coded my website fully in oop and made all its content loads dynamically from MYSQL (simple small CMS) but i have no clue how to join template and php into index without repeating my self and create different file for each page in my web ! (each file do different jobs of course like file users.php does login and registration and userprofile etc)
Hope my english wassnt too too bad and u could understand my question :D !
My current approach so far:
Mysql table : page_tbl
columns: pagename,LogicFile,templateFile,MetaTag.
index.php?pagename
will check if not already cached or not listed for chacing it will :
Mysql:SELECT * WHERE pagename='$_GET['page']'
loginfiles = cars.php,search.php (will be exploded with , and included)
Template files = will be also exploded and modified according to MetaTag.
Metatag: Serialized assoc array with ['name']=['value'];
Then i start buffer output , replace template with new descriptions and keywords(auto generated)
include logic files
include footer.php (which include the scripts)
am i near to correct rout or still far away ? or am did i lose my track and over killing
If you are unsure whether you want to write your own, or use an existing one.
It is going to be a quite possibly very rewarding experience but a very time consuming one to write your own.
If you have a task at hand that you need to be solved, use an existing one.
That being said there are plenty of templating systems, smarty being the most long-lived one. You can find a short discussion on 5 popular ones at phpbuilder.
You also have entire Frameworks that you might want to consider. They are more than just a templating system, where database stuff, ajax helpers etc are included. Zend, CakePHP, and Codeigniter being popular ones. You can find comparisons of these at phpframeworks.
The best way is to take this route:
parse request data
determine controller which will be used
in controller select layout and template [layout "includes" template, it hold the contents that are common to all pages and template has the request-specific content]
in controller also fetch the data from database [MVP way]
assign data to array and pass it to the layout, it'll pass the data futher to the template
in layout and template use data from that array and construct view
pass everything to the browser
This is the way the frameworks work, and it isn't that bad. ;]
I'm looking to add some custom functionality to a VB installation, but I can't for the life of me find any place to drop code into the VB structure. I know most of the code is pulled from the database, but where can I find a template file, etc where I could add my own code module {like if I wanted to add, say, an open source chatbox to the footer]?
vBulletin is written in PHP, so it should just be a matter of finding the correct .PHP file and adding your code there.
Have you tried looking in footer.php?