Joomla own component settings insert article in popup - joomla

I would like to make a setting to insert article ID in backend.
The scenario is: User can click on a button, window with article list will appear, than can choose the article. Article ID will be stored in component config.
Than I can populate article in frontpage (this part I know)

You need to do the following:
Add path to joomla content article element
Create instance of that element
Display it
`
<?php
// I created the element inside of the view, $this is my View.
// It can be model/view/controller. Does not matter
// Include Element
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'elements' . DS . 'article.php';
// Create Instance
$articleElement = new JElementArticle($this);
// Output article
echo $articleElement->fetchElement('article', 0, $this, 'myparam');
// NOTE: name of article_id element will be myparam[article]
?>
If you want to change the way element looks, you need to overload/modify element. It is pretty easy to do, you can copy site/administrator/components/com_content/elements/article.php, make changes and you will get your own version of element. Do not modify article.php component, you will mess up things for Joomla and if you plan updating your site in future... you'll loose changes after update.

Related

Edit JomSocial Joomla Registration Page & Adding Content

I'm running JomSocial 3.2 on Joomla 3.
I want to add some content to the right side of the registration page.
Some pictures and other contents.
So far, i've been able to get to the "register.index.php" file,
which is the file that displays some of the content in the homepag.
The file is in: "/site_root/components/com_community/templates/default/" folder
but i've not been able to fully edit the whole registration page.
This could be done in many different ways - even without editing any file. Install this extension: http://extensions.joomla.org/extension/advanced-module-manager and when editing module you'll have additional tab called "tasks" There will be field URL, type inside URLs of your registration form. Thanks to this you'll be able to assign modules to registration form.
You could also override for:
ROOT/components/com_community/templates/default/register.index.php
Copy it to:
ROOT/templates/your-template/html/com_community (if you don't have "html" or "com_community" folders, feel free to create them)
Then you may create module position inside file using this code:
$modules = JModuleHelper::getModules( 'reg-positon' );
foreach ($modules as $module) {
$_options = array( 'style' => 'xhtml' );
echo JModuleHelper::renderModule( $module, $_options );
}
Above code creates module position: "reg-positon'. You'll need to type this name manually as it will be not listed on module positions list.
Now you'll need a bit of html to display it on right or left of registration form.

joomla Modules - Between Article or inside Article? What is correct?

I want to place articles and modules on my page. It should look like my scatch:
I am wondering if i can make 4 articles and one module (information box) and place this inbetween those articles, Or should i just create one article wich looks like the hole area (article 1-4 + INformation box)? So far i have tried to do {loadposition infobox-pos} into article 2. But than the box-width is not 100% but 50%.
Than aggain if i would make one big article with the contents from article 1-4 it would not fit great into my responsive layout.
I use T3-Framework.
Joomla doesn't support this natively, since module output is controlled by the template, and component output (in this case, com_content, view=category, layout=blog) is handled before modules are rendered.
You can proceed in many ways, I am listing them in order of decreasing ease:
Write a jquery script that moves the pieces in the browser. You could also use mootools and it's bundled with joomla, but odds are you already have jquery loaded anyways.
Write a view override for abovementioned view: so copy /components/com_content/view/category/tmpl to /templates/your_template/html/com_content/category (copy all files). Then edit blog.php and insert your module there, use something like /plugins/content/loadmodule/loadmodule.php :
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$modules = JModuleHelper::getModules($position);
$params = array('style' => $style);
foreach ($modules as $module) {
echo $renderer->render($module, $params);
}
Write a content plugin
you can also use {loadmodule YourCustomModuleTitle} and place this in <div> with custom style attributes like
<div style="width:100%;float:right">{loadmodule MyModule}</div>
or
<div class="something">{loadmodule MyModule}</div>
Note: the module which loaded must be assigned to the same menu item or "all"

Magento Order PDF logo function

I'm using an add Print order button to print a customer's order (not invoice) and I can't figure out how to get the logo to show up on the pdf. The following is the code that is in the extension but I can't find the function to manipulate it and I don't understand why it's not pulling the logo that I have in configuration. Please advise. :)
$this->insertLogo($page, $order->getStore());
You probably don't have store logo for PDF set. In admin you should go to
System -> Configuration -> Sales -> Sales -> Invoice and Packing Slip Design
and set your logo there.
Now for the logn explanation in case the above won't work :)
insertLogo function is located in class Mage_Sales_Model_Order_Pdf_Abstract (I asume that your class derives from it).
The rows that you should note are $image = Mage::getStoreConfig('sales/identity/logo', $store); and $image = Mage::getBaseDir('media') . '/sales/store/logo/' . $image;
getStoreConfig function is looking for the name of logo image in core_config_data table. You can check if the value is set with
SELECT * FROM core_config_data WHERE path = 'sales/identity/logo'
If the query won't return anything or will return value that is not an image name then you'll have to set that value first.
If that value is set you should have a look in
/your_store_root_dir/media/sales/store/logo/value_that_is_in_the_database
to see if the store logo image realy exists and if it doesn't add it there.
Did you check code in that class ($this) and/or its parent class? You'll see function inserLogo there.

How can I load a template of a view within another view in a component?

I am trying to add a view that I made (a table) to another view that I need to appear again. How can I do this? Actually I am trying to add a view within another view using theloadtemplate function.
This is what I type inside the view, but it does't seem to work, can anyone help?
The message I get is the following
Layout default_reports not found
<div>
<?php $jinput = JFactory::getApplication()->input;
$jinput->set('view', 'reports');
echo $this->loadTemplate("reports");
$jinput->set('view', 'master');?>
</div>
But the view is there...
Using the loadTemplate function, we call only the layout inside the view.
We concatenate two or more layout using the loadtemplate inside the following view.
By default joomla, it call the layout by a prefix as default_. So we have to create a layout as reports means filename as default_reports.php but we need to call the layout as you have mentioned
echo $this->loadTemplate("reports");
If you want to be able to load "layouts" from another "view" in the current view.html.php file, then you can do so as below.
$this->addTemplatePath(JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'anotherview' . DIRECTORY_SEPARATOR . 'tmpl');
$this->setLayout('layoutfromanotherview');

Override components/com_users/models/forms/login.xml - Joomla 2.5?

I've been trying to override the file login.xml but no matter what I try, the edited version in my template folder doesn't show up.
How can I override this file?
Update
I have tried template/<templatename>/html/com_users/models/login.xml and other variations like template/<templatename>/html/com_users/models/forms/login.xml or template/<templatename>/html/com_users/forms/login.xml etc without any success.
Here's a solution:
http://forum.joomla.org/viewtopic.php?t=583380#p2375649
I just tested it in Joomla 2.5.3 and it works.
Update
here is the solution copied from above URL
We can override output by using the normal template override feature. For me, I'm trying to override the login page. So, I'm taking a copy of /components/com_users/views/login/tmpl/default.php and putting it into /templates/beez_20/html/com_users/login.
Now take a copy of /components/com_users/models/forms/login.xml and place in /templates/beez_20/html/com_users/login as well.
Then edit /templates/beez_20/html/com_users/login/default.php and add at the top of the form (I added mine just after the form tag) the following lines of code:
// to reset the form xml loaded by the view
$this->form->reset( true );
// to load in our own version of login.xml
$this->form->loadFile( dirname(__FILE__) . DS . "login.xml");
Similarly you can safely edit /templates/beez_20/html/com_users/registration/registration.xml to modify the registration form.
The answer posted in the forum that #Shaz definitely works, but for Joomla 3.X you have to tweak a little, so it would be
First of all you copy
/components/com_users/models/forms/login.xml
To
/templates/YOUR_TEMPLATE/html/com_users/login/forms/login.xml
And place this piece of code right at the top
if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
$this->form->reset( true ); // to reset the form xml loaded by the view
$this->form->loadFile( dirname(__FILE__) . DS . "forms" . DS . "login.xml"); // to load in our own version of login.xml
This did the tick for me a kudos for the user #dylanjh that posted the original answer on the Joomla forum
I was able to leverage Griiettner's solution for Joomla 3. I wanted to not allow users to edit their email address in the profile edit screen on the frontend. I only modified it slightly, copy this file:
components/com_users/models/forms/profile.xml
to:
/templates/YOUR_TEMPLATE/html/com_users/profile/forms/profile.xml
Also copy this file:
components/com_users/views/profile/tmpl/edit.php
to:
/templates/YOUR_TEMPLATE/html/com_users/profile/edit.php
And put this code at the top of the edit.php file right after the:
defined('_JEXEC') or die;
I left out the $this->form->reset( true ); // to reset the form xml loaded by the view
and only used this:
// JOOMLA 3
if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
$this->form->loadFile( dirname(__FILE__) . DS . "forms" . DS . "profile.xml");
This allowed me to keep the user profile information populated in the edit form. I then edited the profile.xml file and added:
readonly="true"
to the email1 and email2 fields. This prevents the user from editing.

Resources