Joomla, static text after every article - joomla

Is there anyone who knows how to add piece of code under every article of joomla. Joomla version 1.5.
Whitch files I should edit or maybe theres some plugin or component?

You can create a system/content plugin
which should work on onPrepareContent trigger
function onPrepareContent($item, $params, $limitstart)
{
// append text in $item->text
}

one other way can be in template you override the view of com_content and add some static text in there. Simple thing you can try is go to
\components\com_content\views\article\tmpl\ pick default.php from there and put it in templates\template_name\html\com_content\article\
now here change the default.php to contain that static text.

if you need some text/html (not php code), than you can use this plugin: http://extensions.joomla.org/extensions/style-a-design/articles-styling/7404
- it has a lot of configuration options

Related

How to add a link dynamically to product listing page without chaging phtml?

I ant to add a link with each product on product listing page (link add to wishlist link). But I don't want to add it through changing "catalog/product/list.phtml".
Is it possible to do it though layout xml or jquery?
Any suggestions would be appreciated.
You can create a new block in XML, but you will also have to create a template file, assign that template to new block. To display it in list.phtml you will nee to call $this->getChildHtml('wishlist_link_block');
Simplest and easiest solutions are sometimes the best so I really think that changing list.phtml is the best place to do it.
Event.observe(window, 'load', function() {
$$('.parent-class-of-all-products-wraper').each(function(c){
c.insert(new Element("a",{id:"anch_id"}));
});
});

Joomla replace String in article content with PHP Code

I´m working on a Joomla 2.5 site. The goal is to give the authors an easy way to output a list of categories when editing an article.
For this I wrote a small PHP Script which querys the needed content from the Db:
switch ($year) {
case "2009":
$id = "42";
break;
...
$db->setQuery('
SELECT
#__categories.title
FROM
#__categories
WHERE
#__categories.parent_id =' . $id .'
ORDER BY #__categories.title ASC
'
);
$winners = $db->loadObjectList();
foreach($winners as $gewinner){
echo $gewinner->title . "<br />";
}
...
The Script takes a year as Input and uses it as $id.
I´ve now looking for a way to easily integrate this into joomlas article editor. Great would be if the authors could insert something like
###2011###
which then is converted to:
<?php
require_once '/homepages/16/d60007267/htdocs/content/testpage/templates/test/winners.php?j=2009';
?>
when the article is rendered. I thought I could make an com_content override. But haven´t found a good point where to search and replace within the content.
thanks for help,
tbook
You have to look at content plugins and maybe editors-xtd plugins.
The content plugin will detect the special markup you put into the article and do whatever you need it to do with it. That is your whole script code should go into this plugin, not the require_once stuff. Usually plugin markup uses { and }, but you could use anything you want. You just create a proper REGEX for it to detect.
If this works you can also look at an editors-xtd plugin. This will then create a button below the editor which allows your authors to input the markup into the editor.
For examples, you can look at one of the simpler existing plugins.

Joomla 2.5.8. How to display only article or module content in modal box popup.

I want to put login module in to modal popup. But when I use class="modal" whole page gets loaded in to modal. Can you show me the way to put only module.
This stands also for displaying articles in modal.
here is the link with problem
I do this fairly often and there are two tricks that can help make this work better. First you will likely want to add tmpl=component to your url. This causes Joomla to only display the article instead of the entire template (as long as your template supports this, most do).
This should do pretty well. If you want to get even more selective, you can do one of two things:
Add CSS to hide pieces
.modal-body .other-selector {
display:none;
}
Use Javascript to select only the piece that you want
$('#myModal').on('show', function () {
// selects a piece of the current modal body and sets it as the only content of the modal
$('#myModal .modal-body').html($('#myModal .modal-body').find('.other-selector).html());
})
The way you can only display the component is to add an extra parameter tmpl=component in the url.If you'll see the component.php inside your template folder that has mainly <jdoc:include type="component" /> with no module position.So it'll load only component.
I did not try for module but you can try similar for module.So you can try it by just giving the position of the module in whole template like create a new page called modules.php in your template folder and put the module position inside this page.And you call it in a similar way just like component like tmpl=modules
I hope this will work.
It was problem with my templates component.php file. I just added inside and now it works fine. Thanks guys

Joomla: Override Category Blog output multiple times?

Yes. I want to override output of Category Blog component to 2 different display styles.
For first style, i copied and edited blog_item.php & blog.php in [mytemplate]/html folder. Then i choose template style from dropdown in backend of my category blog. That's worked. The display of category blog change as i expected.
But if i want to create another style and use in another category blog. How could i do ? And how to i named my files ( I tried blog_1.php, blog_item_1.php ) but only see my first style display in backend.
I'm using joomla 2.5.
Please help me. Thank you very much !
=================================================================================
[UPDATED]
I solved this issue. Here my solution:
Clone my template to [my_template_2]
Go to [my_template_2]/html/com_content/category then edit blog.php, blog_item.php as my needs.
Go to backend, at my category blog menuitem, i assigned [my_template_2] as its template style.
Then it worked. Both my category blog have its own style.
This maybe not very good solution because i have to use multiple templates, but at this time it's quite enough for me.
Thank you, stackoverflowers.
=================================================================================
[UPDATED 2]
Now, with multiple template styles, I could create unlimited styles for my category blog component within just only one template. That's very much better.
As you may know, joomla doesn't let developers make different styles for its components.
I think you have to list all menus which are made by "category blog component" in template managing page and let users set each menu style at there.**
and at blog.php, check template setting and then load customized style...
** you have to develop a custom field element which list all "category blog component" menus.
* you can use this code to accessing template parameters in component's template :
$app =& JFactory::getApplication();
$template = $app->getTemplate(true);
$paramsTemplate = $template->params;
$style = $paramsTemplate->get('style');
You don't need to use multiple styles. What you need is to use alternate layouts and alternative menu layouts.
For alternative menu layouts in the html/componentname/category folder of your template make a new style with a unique set of names similar to the way blog already provides an alternative to category list in the article category layout folder. Also make a new xml file for each layout that you make, with a matching name.
When you create your menu item you will now get these alternatives along with your other normal choices. Just select the one you want.
Based on the learnings above here is my code for the /templates/mytheme/com_content/category/blog.php
And then in the Global Configuration > Article Manager Options > Category choose Blog as the override/ layout.
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
$pageclass_sfx = trim($this->pageclass_sfx);
// so pick it on the page class in menu item
if (isset($pageclass_sfx) && $pageclass_sfx != '') {
echo $this->loadTemplate($pageclass_sfx);
} else {
echo $this->loadTemplate('default');
}
I can add multiple elseif if something else is needed, or it will look for 'blog_' . $this->pageclass_sfx . 'php'. It is always beginning blog_ as thats coded into the com_content. The old blog i moved to blog_default.php and blog_default_item.php

How to call a custom php file on magento product page

if getChildHtml('product_type_data') ?> maps directly to catalog/product/view/type/simple.phtml by default, how do I map to my own file? If I wanted to create a file that would produce a small image to place on the product page, right under "availability" how would I tell magento to map to where I have put the file? From what I understand getChildHtml('product_type_data') ?> defaults to the file path: catalog/product/view/type/simple.phtml so how can I customize the magento defaults and tell it to map to my custom files i've created?
Could I do something like getChildHtml('etc/etc/my-file.phtml') ?>
Essentially, what I am trying to do is add a small image under "availability" of my site (ex: http://climbhigh.com/climbing/climbing-ropes/petzl-dragonfly-rope-8-2mm.html) that says free shipping. Just trying to find the best way to do it.
I hope I have explained this well enough, if not, please let me know and I will try to explain more. Any help or guidance would be awesome. Thanks.
The code getChildHtml('product_type_data') doesn't always map directly to the template file catalog/product/view/type/simple.phtml. It only maps to that file if the layout handle PRODUCT_TYPE_simple is loaded, i.e. if the current product is a simple product. In order to change the template to be a different one you need to update the template attribute in the layout. At it's most simple this can be achieved by editing app/design/frontend/base/layout/catalog.xml and changing the template attribute.
<block type="catalog/product_view_type_simple" name="product.info.simple" as="product_type_data" template="your/new/path.phtml">
Of course editing core files is a bad idea, so you should make a quick search for how to correctly add layout updates via either local.xml or customer layout update files.
I ended up figuring out what I needed to do. I simply wanted to add a small image to my product detail page that highlight a free shipping option. All I had to do was create a static block in the admin panel of magento and go into catalog>product>view.phtml file and insert:
getLayout()->createBlock('cms/block')->setBlockId('your_block_id')->toHtml(); ?>
it worked like a charm!
thanks for the help Crags

Resources