I am building a Stripe subscription PHP website using Laravel I am getting this error when I am trying to check if user is subscribed.
The error is in the view Laravel says its on this line #if ($user->subscribed()).
My code:
#extends('temp.main')
#section('content')
#if ($user->subscribed())
<p>Subscribed</p>
#else
<p>Not Subscribed </p>
#endif
#stop
The error:
Call to a member function subscribed() on null
<?php $__env->startSection('content'); ?>
<?php if($user->subscribed()): ?>
<p>Subscribed</p>
<?php else: ?>
<p>Not Subscribed </p>
<?php endif; ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('temp.main', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
You need to check Auth::check() before using Auth::user()
Something like this:
#if (Auth::check() && !$user->subscribed())
Related
I have an paginator that I use for my forum.
The problem is, when I include this, it displays on every page, including the pages that doesn't need to have the pagination jet.
How Can I fix this?
Now I have this to display my pagination:
{{ $comments->links() }}
I guess that you changed the default view for a paginator to your own - because Laravel hides pagination when it isn't needed.
This is how Laravel handles this:
<?php
$presenter = new Illuminate\Pagination\BootstrapPresenter($paginator);
?>
<?php if ($paginator->getLastPage() > 1): ?>
<ul class="pagination">
<?php echo $presenter->render(); ?>
</ul>
<?php endif; ?>
you can find it in:
vendor/laravel/framework/src/Illuminate/Pagination/views/slider-3.php
I have a custom attribute for products in which I add a video URL.
I made this Embed video responsive using css.
Now I want to call the custom attribute on the product page, so it shows the video.
The file responsible for this is: description.phtml
I've tried the following:
?>
<?php $_description = $this->getProduct()->getDescription(); ?>
<?php if ($_description): ?>
<h2><?php echo $this->__('Details') ?></h2>
<div class="std">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?>
</div>
<div class="std">
<?php echo $_product->getAttributeText('video') ?>
</div>
<?php endif; ?>
But I get the error:
Fatal error: Call to a member function getAttributeText() on a non-object in /data/web/public/app/design/frontend/base/default/template/catalog/product/view/description.phtml on line 40
The video does show however. I'm probably doing this all wrong. Can I fix this with a simple edit of the code, or do I have to use an entirely different approach?
Thanks.
<?php echo $this->getProduct()->getAttributeText('video'); ?>
Try this. Or on top of document add this
<?php $_product = $this->getProduct(); ?>
Well we are not able to get the products to display in the product sitemap which is by default available in magento at (http://sitename.com/catalog/seo_sitemap/product/).
We have the following code present in the app/design/frontendbase/default/template/catalog/seo/sitemap.phtml
<?php
/**
* #see Mage_Catalog_Block_Seo_Sitemap_
*/
?>
<?php $_items = $this->getCollection(); ?>
<? //var_dump($_items);?>
<?php if($_items->getSize()): ?>
<ul class="sitemap">
<?php foreach ($_items as $_item): ?>
<li><?php echo $this->escapeHtml($_item->name) ?></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p class="note-msg">
<?php echo $this->__('There are no %s available.', $this->getItemsTitle()); ?>
</p>
<script type="text/javascript">
//<![CDATA[
if ($('sitemap_top_links') != undefined) {
$('sitemap_top_links').hide();
}
//]]>
</script>
<?php endif ?>
We tried to var_dump($_items) the product sitemap page and we were able to get the data dump of product however $_items->getSize() returns 0 and the foreach is not able to parse the $_items array.
Is there a magento backend setting or a product attribute that controls the sitemap behavior. Also the category sitemap seems to be working fine so the issue is specific to products.
I'm using the AheadWorks blog extension for Magento, and my blog pages are working fine. But I want excerpts of my latest posts from certain categories to appear on my home page. I've successfully setup everything thus far by adding:
<block type="blog/blog" name="blog.latest" template="aw_blog/blog-home.phtml" />
to "layout.xml", by adding:
<?php echo $this->getChildHtml('blog.latest') ?>
to my home page's phtml file, and by creating "template/aw_blog/blog-home.phtml".
The problem is that I can't figure out how to limit what categories are shown. For example, you'll see in my "blog-home.phtml" file below that I'm trying to limit the posts to the "news" category. I've tried lots of solutions from other forums, but no matter what I do, I see posts from every category. Does anyone know what I need to add/take away from my code to limit the categories?
<?php $posts = $this->getPosts("news"); ?>
<div id="messages_product_view">
<?php Mage::app()->getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton('customer/session')->getMessages(true)); ?>
<?php echo Mage::app()->getLayout()->getMessagesBlock()->getGroupedHtml(); ?>
</div>
<?php $numberOfPosts = 1 ?>
<?php $renderedPosts = 0 ?>
<?php foreach ($posts as $post): ?>
<div class="postWrapper">
<div class="postTitle">
<h2><a href="<?php echo $post->getAddress(); ?>" ><?php echo $post->getTitle(); ?></a></h2>
</div>
<div class="postContent"><?php echo $post->getPostContent(); ?></div>
<?php echo $this->getBookmarkHtml($post) ?>
<div class="tags"><?php echo $this->getTagsHtml($post) ?></div>
<div class="postDetails">
<?php if ($this->getCommentsEnabled()): ?>
<?php echo $post->getCommentCount(); ?> <a href="<?php echo $post->getAddress(); ?>#commentBox" >Comments</a> |
<?php endif; ?>
<?php $postCats = $post->getCats(); ?>
<?php echo "<h1>" . $postCats[2] . "</h1>"; ?>
<?php if (!empty($postCats)): ?>
<?php echo Mage::helper('blog')->__('Posted in'); ?>
<?php foreach ($postCats as $data): ?>
<?php echo $data['title']; ?>
<?php endforeach; ?>
<?php else: ?>
<?php endif; ?></div>
<?php $renderedPosts ++ ?>
<?php if ($renderedPosts = $numberOfPosts) {
break;
}
?>
</div>
<?php endforeach; ?>
<?php //$this->getPages(); ?>
Following is the quick solution:
Go to aw_blog frontend template, default might be this app/design/frontend/base/default/template/aw_blog/menu.phtml
check and replace:
if ($posts = $this->getRecent():
with
$currentBlogCat = Mage::getSingleton('blog/cat');
if ($posts = $this->getRecent($currentBlogCat['cat_id'])):
Now open up /app/code/community/AW/Blog/Block/Menu/Sidebar.php
check for the below function:
public function getRecent()
add a parameters to it:
public function getRecent($currentCat=false)
Also, replace the following code block
$collection = clone self::$_collection;
if (array_key_exists('categories',$data = $this->getData();) && count(explode(',', $data['categories'])) == 1) {
with
$collection = clone self::$_collection;
$data = $this->getData();
if($currentCat>0)$data['categories']=$currentCat;
# Category fix #
if (array_key_exists('categories',$data ) && count(explode(',', $data['categories'])) == 1) {
Thanks!
I have the following form:
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'new-agenda-entry',
'enableAjaxValidation'=>true,
'action'=>'')); ?>
<div class="four columns">
<div class="right top5 sufix10">
<?php echo $form->labelEx($model,'eventTime'); ?>
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>'UserAgenda[eventTime]',
'model'=>$model,
'options'=>array(
'dateFormat'=>'yy-mm-dd',
'minDate'=>'new Date()',
) // jquery plugin options
));?>
<?php echo $form->error($model, 'eventTime'); ?>
</div>
<div class="right top5 sufix10">
<?php echo CHtml::dropdownList('eventTime_hour', false, $this->getHourArray()); ?>
<?php echo CHtml::dropdownList('eventTime_min', false, array('00'=>'00', '30'=>'30')); ?>
</div>
<?php echo $form->labelEx($model,'note'); ?>
<?php echo $form->textField($model, 'note');?>
<?php echo $form->error($model, 'note'); ?>
The model is successfully validated on the server as I can see the response in Firebug:
{"UserAgenda_eventTime":["Event time cannot be blank."],"UserAgenda_note":["Note cannot be blank."]}
The message seems fine, so does the html but the hidden inputs generated by yii remain hidden and empty.
in the action maybe (create or update) you have to uncomment // $this->performAjaxValidation($model); like this you have an ajax validation, if the problem persist I think posting it to yiibootstrap discussion in yii forums i better, I see that you use yiibootstrap, try it with default yii form widget.