I am using Osclass 3.5.3. In my log file, I keep seeing the following error:
"PHP Warning: implode(): Invalid arguments passed in"
The lines in question are:
<!-- <small><?php _e("Location", 'aiclassy');?>: <cite title="<?php echo implode(', ', $location); ?>"><?php echo osc_user_city(); ?><span class="glyphicon glyphicon-map-marker"></span></cite></small><br /><br /> -->
<!-- <span class="glyphicon glyphicon-envelope"></span> <?php printf(__('%s', 'aiclassy'), osc_item_contact_email()); ?><br /> -->
The whole code is wrapped up in like this:
<div class="well">
<div class="row">
<div class="col-sm-12">
<!-- <small><?php _e("Location", 'aiclassy');?>: <cite title="<?php echo implode(', ', $location); ?>"><?php echo osc_user_city(); ?><span class="glyphicon glyphicon-map-marker"></span></cite></small><br /><br /> -->
<!-- <span class="glyphicon glyphicon-envelope"></span> <?php printf(__('%s', 'aiclassy'), osc_item_contact_email()); ?><br /> -->
<?php osc_run_hook('item_detail', osc_user() ); ?>
<?php //voting_item_detail_user(); ?>
</div>
</div>
</div>
How do I resolvethis...any suggestions, please? Thank you, all.
If you are unsure about if the value for $location is an array or a string you could decide it right away when echoing the value.
<?php echo is_array($location) ? implode(', ', $location) : $location; ?>
This is meant as a replacement for the current
<?php echo implode(', ', $location); ?>
You need to pass an array to implode seconds parameter.
See the documentation here.
Related
I am writing a custom landing page in PHP parsing an XML product feed. The product descriptions are very long, as it goes into technical information and specifications, so need to be condensed to read the first 200 characters. hopefully with a read more link once 200 characters has been reached.
The code I have so far is:
<?php
$xml = simplexml_load_file('feed.xml');
foreach ($xml->item as $item) { ?>
<div class="row">
<div class="lhs">
<h3><?php echo $item->brand.' '.$item->title ?></h3>
<p class="pri">£<?php echo $item->price ?></p>
<p><?php echo $item->description; ?></p>
</div>
<div class="rhs">
<img src="<?php echo $item->image_link ?>" alt="<?php echo $item->title ?>" height="150" />
</div>
</div>
<?php
}
?>
Please could anyone advise what else I need to add? I can follow basic patterns in PHP, I just need some guidance.
Many thanks in advance.
Notice the $short_description line.
Edited with some basic js example of "Show more"
<?php
$xml = simplexml_load_file('feed.xml');
foreach ($xml->item as $item) {
$short_description = substr($item->description, 0, 200);
?>
<div class="row">
<div class="lhs">
<h3><?php echo $item->brand . ' ' . $item->title ?></h3>
<p class="pri">£<?php echo $item->price ?></p>
<p id="shown"><?php echo $short_description; ?>... Show more</p>
<p id="hidden"><?php echo $item->description; ?></p>
</div>
<div class="rhs">
<img src="<?php echo $item->image_link ?>" alt="<?php echo $item->title ?>" height="150" />
</div>
</div>
<?php
}
?>
Hi I have this error in my website
my website is wordpress 4
i use post format
in post format i create this php to if page has quote post then dont load title and image and etc from quote post just show quote content is meta box (wordpress)
Notice: Use of undefined constant quote - assumed 'quote' in C:\xampp\htdocs\personal\wp-content\themes\personal\warp\systems\wordpress\layouts\_post.php on line 4
and
Notice: Use of undefined constant quote - assumed 'quote' in C:\xampp\htdocs\personal\wp-content\themes\personal\warp\systems\wordpress\layouts\_post.php on line 14
this is _post.php code in bellow
<?php $format = get_post_format(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('group'); ?>>
<?php
if ($format != quote ) {
$css_class = "b-box";
} else {
$css_class = "q-box";
}
echo "<div class=\"$css_class\">";
?>
<?php get_template_part('inc/post-formats'); ?>
<?php if ($format != quote ) : ?>
<div class="post-content">
<div class="blog-img-box">
<img src="<?php echo catch_that_image() ?>" alt="<?php the_title(); ?>" />
</div>
<div class="post-deco blog-icon-box">
<div class="hex hex-small">
<i class="fa blog-icon"></i>
<?php if ( $format != false ) :?><?php endif; ?>
</div>
</div><!--/.post-deco-->
<h2 class="blog-title">
<?php the_title(); ?>
</h2><!--/.post-title-->
<div class="blog-details row">
<div class="col-md-4"><i class="fa fa-calendar blog-details-icons"></i>
<p class="blog-details-icons-txt"><?php the_time('j M, Y'); ?></p>
</div>
<div class="col-md-4">
<a href="<?php comments_link(); ?>">
<i class="fa fa-comment blog-details-icons"></i>
<p class="blog-details-icons-txt"><?php comments_number( '0', '1', '%' ); ?> Comments</p></a>
</div>
<div class="col-md-4"><i class="fa fa-eye blog-details-icons"></i>
<p class="blog-details-icons-txt"><?php echo getPostViews(get_the_ID()); ?></p>
</div>
<div class="likes"><i class="fa fa-heart blog-details-icons"></i>
<p class="blog-details-icons-txt">18</p>
</div>
</div>
<div class="blog-txt">
<?php the_excerpt(); ?>
</div>
<div class="readmore-box"><p class="readmore-txt"><?php _e('Read More','anew'); ?></p></div>
</div><!--/.post-content-->
<?php endif ?>
</div><!--/.post-inner-->
</article><!--/.post-->
please check and say to me what i wrong
thank you !
If you want to use the quote as a literal string (line 4), not a variable name, you must enclose it into single or double quote characters (' or "). Otherwise, PHP thinks that you're referencing a PHP constant.
For reasons of backward compatibility, PHP falls back on using the string as literal, but it does throw an E_NOTICE error – the one you're experiencing.
verify that all variables have this sign $
correct variable $test
incorrect variable test
I'm making a website with Joomla and am using RokSprocket to display some news. Now, some Titles are too long, so I wanted to shorten it after a certain character number, but it's not working. Am a total php noob, my apologies.
Here's the whole code:
<li data-lists-item>
<h4 class="sprocket-lists-title ">
<?php if ($item->custom_can_have_link): ?><a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>"><?php endif; ?>
<?php if(strlen($item->getTitle)>10)
echo substr($item->getTitle,0,10) . ' ...';
else
echo $item->getTitle();?></a>
<div class="date"><?php echo date('d.M. Y', strtotime($item->getDate()));?></div>
</h4>
<span class="sprocket-lists-item" data-lists-content>
<span class="sprocket-padding">
<?php if ($item->getPrimaryImage()) :?>
<img src="<?php echo $item->getPrimaryImage()->getSource(); ?>" class="sprocket-lists-image" />
<?php endif; ?>
<?php echo $item->getText(); ?>
<?php if ($item->getPrimaryLink()) : ?>
<span><?php rc_e('READ_MORE'); ?></span>
<?php endif; ?>
</span>
</span>
</li>
I'm hoping it's something very obvious and I'm just being stupid. Thanks a bunch already!
$item->getTitle is probably a method not a property, so try:
$item->getTitle(); // <-- parenthesis
Change to:
<?php if(strlen($item->getTitle())>10)
echo substr($item->getTitle(),0,10) . ' ...';
this code out put is here....(look at the footer subscribe section )
<?php if(!empty($this->items))foreach($this->items as $level): ?>
<?php
$formatedPrice = sprintf('%1.02f',$level->price);
$dotpos = strpos($formatedPrice, '.');
$price_integer = substr($formatedPrice,0,$dotpos);
$price_fractional = substr($formatedPrice,$dotpos+1);
?>
<div class="level akeebasubs-level-<?php echo $level->akeebasubs_level_id ?>">
<p class="level-title">
<span class="level-price">
<?php if(AkeebasubsHelperCparams::getParam('currencypos','before') == 'before'): ?>
<span class="level-price-currency"><?php echo AkeebasubsHelperCparams::getParam('currencysymbol','€')?></span>
<?php endif; ?>
<span class="level-price-integer"><?php echo $price_integer ?></span><?php if((int)$price_fractional > 0): ?><span class="level-price-separator">.</span><span class="level-price-decimal"><?php echo $price_fractional ?></span><?php endif; ?>
<?php if(AkeebasubsHelperCparams::getParam('currencypos','before') == 'after'): ?>
<span class="level-price-currency"><?php echo AkeebasubsHelperCparams::getParam('currencysymbol','€')?></span>
<?php endif; ?>
</span>
<span class="level-title-text">
<a href="<?php echo JRoute::_('index.php?option=com_akeebasubs&view=level&slug='.$level->slug.'&format=html&layout=default')?>">
<?php echo $this->escape($level->title)?>
</a>
</span>
</p>
<div class="level-inner">
<div class="level-description">
<div class="level-description-inner">
<?php if(!empty($level->image)):?>
<img class="level-image" src="<?php echo JURI::base()?><?php echo trim(AkeebasubsHelperCparams::getParam('imagedir','images/'),'/') ?>/<?php echo $level->image?>" />
<?php endif;?>
<?php echo JHTML::_('content.prepare', AkeebasubsHelperMessage::processLanguage($level->description));?>
</div>
</div>
<div class="level-clear"></div>
<div >
<button onclick="window.location='<?php echo JRoute::_('index.php?option=com_akeebasubs&view=level&slug='.$level->slug.'&format=html&layout=default')?>'">
<?php echo JText::_('COM_AKEEBASUBS_LEVELS_SUBSCRIBE')?>
</button>
</div>
</div>
</div>
<?php endforeach; ?>
this is the language file contain that name
COM_AKEEBASUBS_LEVELS_SUBSCRIBE="Subscribe Now"
I want to name those three sections butons as 6month,12month,24month
How will change the code ?
If you are unable to get the value using PHP, try changing the value of the button's name on page load
Here is the JQUERY
$(document).ready(function){
$('div.akeebasubs-awesome-description').each(function(
substription = $(this).children('H4').html()
button = $(this).parent().next().children('button')
$(button).attr(name,substription.split(' ')[0]+'month')
})
})
and the JAVASCRIPT
divs = document.getElementsByClassName('akeebasubs-awesome-description');
for (var i in divs){
divs[i].parentElement.nextElementSibling.children[0].name = divs[i].children[0].innerHTML.split(' ')[0] + 'month'
}
This will take the text of the H4 and make that the corresponding button's name
In the CMS i'm working on I'm using a foreach statement to display the returned database results.
but ever page load I get an error message saying the foreach statement im using has an invalid argument
here's the statement
<?php foreach ( $presults as $post ) { ?>
<!-- Post Frames -->
<div class="outerPost_frame">
<div class="postScreen">
<!--post date hidden show on hover -->
<span class="date_">
<p><?php echo date('j F', $post->date) ?></p>
</span>
<!-- post title -->
<span class="name_">
<p><?php echo htmlspecialchars($post->name) ?></p>
</span>
<span class="content_">
<?php echo $results['post']->content ?>
</span>
</div>
</div>
<?php } ?>
Try casting $presults to an array.
<?php foreach ( (array) $presults as $post ) { ?>
How are you setting up your array, could be a problem, but we would need an error msg to know for sure.
Try this though
<?php foreach ( $presults as $post ) { ?>
<!-- Post Frames -->
<div class="outerPost_frame">
<div class="postScreen">
<!--post date hidden show on hover -->
<span class="date_">
<p><?php echo date('j F', $post[date]) ?></p>
</span>
<!-- post title -->
<span class="name_">
<p><?php echo htmlspecialchars($post[name]) ?></p>
</span>
<span class="content_">
<?php echo $post[content] ?>
</span>
</div>
</div>
<?php } ?>