joomla get page body - joomla

How to do in joomla:
<jdoc:include type="component" />
using php. I want to get page body by for example menu id, or menu link.
I know that for module I can use:
$module = &JModuleHelper::getModule('mod_module');
$result = JModuleHelper::renderModule($module);
But what about content

Related

How to load a menu module in header and footer in joomla?

I have attached joomla's Menu module in my template. But I needed it to load in footer position at the same time. So that if I add another menu it should be get added in both the positions in Header and in the footer... What i want to do to load a menu module to two different positions in a page, in header and in footer.
I had tried to add multiple positions in administrator section for a menu module...
screen shots are as follows
For latest version. Joomla3.x :
Get all the modules by template position(replace position with your template position):
<?php
$modules = JModuleHelper::getModules("position");
$document = JFactory::getDocument();
$attribs = array();
$attribs['style'] = 'xhtml';
foreach ($modules as $mod) {
echo JModuleHelper::renderModule($mod, $attribs);
}
?>
Other Solution: you can define position in the template and assign module to that position
Steps:
1.Customize templateDetails.xml file
add
newposition
2.create position in index file of template
in templates/your_template/index.php
<jdoc:include type="modules" name="newposition" />
If I understand correctly, you should simply be able to duplicate your menu module (in extensions->modules) and add the duplicate module to a module position in the footer of your template. If there is no module position in the footer, you add one to the - list in templateDetails.xml, and add it to index.php in your template, like:
<jdoc:include type="modules" name="footer-menu" style="xhtml" />

joomla templating custom JDOC statements

Which Joomla Platform / CMS class should I extend in order to make my own custom JDOC:include tags?
I would like to have custom JDOC tags like
<JDOC:include type="scripts" />
<JDOC:include type="scripts-body" />
and a bunch of other types.
You need to add new file at below location to add custom jdoc tag..
libraries/joomla/document/html/renderer/
File name should be same as the tag you are adding.. suppose you want to use scripts as tag then file name should be scripts.php
Now in this file you need to add below code. as tag name is scripts so class name should be JDocumentRendererScripts
<?php
defined('JPATH_PLATFORM') or die;
class JDocumentRendererScripts extends JDocumentRenderer
{
public function render($scripts, $params = array(), $content = null)
{
$contents = "";
//Do your work here
return $contents;
}
}
?>
Now you can use custom jdoc code <JDOC:include type="scripts" />
Hope this helps..

Hide a paragraph of static block /cms page from wholesale customer group in magento

i'm using CMS pages and Static Blocks and would like to hide a text paragraph from showing it to a wholesale group.
is this possible with magento? Kindly help.
Magento 1.8.1
If,you want to hide a text paragraph from ,then first check wholesaler is logged in or not, then check current customer group is wholesaler.
Here code add in header.phtml
<?php
if(Mage::getSingleton('customer/session')->isLoggedIn() and Mage::getSingleton('customer/session')->getCustomerGroupId()==2 ){
?>
<script type="text/javascript">
document.getElementById("noforid").style.display=none;
</script>
/* using jquery*/
<?php
// do not show paragraph
//Get customer Group name
$group = Mage::getModel('customer/group')->load($groupId);
}
else{
?>
<?php
// text paragraph of your
}
?>
And put you content in a html element and put id of element.Using java-script hide the content.
<p id="noforid">your text</p>

"add your review" link in product view page doesn't work after upgrading to 1.8

I recently upgrading from magento 1.5 to 1.8, after upgrading "add your review" link return a URL like /review/product/list/id/250/#review-form. this URL show up a 2 col-right template where my page is 2 col-left design....before upgrading I use below method to show review on product view page.
I add below code before closing of "catalog_product_view" handle in catalog.xml.
<block type="review/product_view_list" name="product.info.product_additional_data" as="product_review" template="review/product/view/list.phtml">
<block type="review/form" name="product.review.form" as="review_form"/>
</block>
then in view.phtml under catalog/product add a call
<?php echo $this->getChildHtml('product_review') ?>
Every thing is fine in version 1.5 and when clicking "add your review" link, it return URl like www.mystore/product URL|#review-form, (this is different from version 1.8), so the display screen just jump to position of page defined by ID "review-form" on the same page instead of new URL like version 1.8 does..
I have checked "add your review" link was generated by function "getReviewsSummaryHtml" which is not changed from 1.5 to 1.8. also nothing changed in review.xml from 1.5 to 1.8. so I am getting lost.
my 1.5 version was created by other developer, may be some thing has to be done some where else before using above method to show review on product page....why the same function getReviewsSummaryHtml returning different URL which code look same from 1.5 to 1.8?
I have found answer. under my 1.5 theme, there is a template/review/helper/summary.phtml which is eventually called by getReviewSummaryHtml function and overridding its base file. with below code
<p class="rating-links">
<?php echo $this->__('%d Review(s)', $this->getReviewsCount()) ?>
<span class="separator">|</span>
<?php echo $this->__('Add Your Review') ?>
</p>
it assign a direct ID to respective link and jump to review portion on the product view page rather than load a review/product/list page in base design. I did not copy that summary.phtml file into my theme after upgrading....
hope this help those using above method to show review on product view page...
I had simmilar problem on Magento2, in my case it was diffrent name for custom tabs and had to override file
vendor/magento/module-review/view/frontend/web/js/process-reviews.js
$(function () {
$('.product-info-main .reviews-actions a').click(function (event) {
var acnchor;
event.preventDefault();
acnchor = $(this).attr('href').replace(/^.*?(#|$)/, '');
$('.product.data.items [data-role="content"]').each(function (index) { //eslint-disable-line
if (this.id == 'smarttabs.reviews.tab') {
$('.product.data.items').tabs('activate', index);
$('html, body').animate({
scrollTop: $('#' + acnchor).offset().top - 50
}, 300);
}
});
});
});
Maybe it will help someone :)

Adding <jdoc:include calls in Component Templates

I'm integrating a component template for a customer. He is using custom templates for com_user / login & reset views.
His site is also using a lot of modules. How can I activate these modules for the component in total, instead of a menu item?
In the module template (user/login/tmpl/default.php) I wrote: <jdoc:include type="modules" name="ja-news" />, which doesn't work.
Thanks for any answers!
BR,
Sebastian
Found the solution in http://forum.joomla.org/viewtopic.php?f=231&t=247191
<?php
$zone = "ja-news";
$modules =& JModuleHelper::getModules($zone);
foreach ($modules as $module){
echo JModuleHelper::renderModule($module);
}
?>
I guess it would be good to have <jdoc:include with an additional force="true" parameter..

Resources