url() problem: Unsupported operand types - drupal-6

I have a problem with print url on view:
<?php foreach ($rows as $id => $row): ?>
<?php print $row; ?>
<?php
?>
<?php endforeach; ?>
I am getting
Fatal error: Unsupported operand types in /{uri}/includes/common.inc on line 1436
Could somebody help me resolve this error?
Regards

Why you don't use l() function? It's a better solution that build your own link.
http://api.drupal.org/api/drupal/includes%21common.inc/function/l/6

Related

EJS, node js forEach loop on include

When using this syntax to loop on a 'component' EJS is complaining that task is not an object but if replaced with task._id it's fine.
Any ideas please?
<? tasks.forEach( function( task ){ ?>
<?- include('_task'); ?>
<? }) ?>
If you're asking how to pass task to your include then it'd be something like this:
<? tasks.forEach(function(task) { ?>
<?- include('_task', {task: task}) ?>
<? }) ?>
Top-level data is automatically included but local variables need to be passed explicitly. See https://github.com/mde/ejs#includes

removing ical download links in DPCalendar Lite calendar listing

I would like to remove the ical download links from the list of calendars in DPCalendar Lite (illustrative bit of screen shot here) but have not been able to find a configuration option for this. Is there a way to do it without editing source? Thanks for any tips.
Well I would still really prefer if there was a configuration option, but for anyone else who wants to do this, the code to modify is in
/com_dpcalendar/site/layouts/calendar/calendarlist.php
starting at line 49, remove or comment out:
<?php
if (!$calendar->external)
{ ?>
[ <a href="<?php echo DPCalendarHelperRoute::getCalendarIcalRoute($calendar->id)?>">
<?php echo JText::_('COM_DPCALENDAR_VIEW_CALENDAR_TOOLBAR_ICAL')?>
</a> ]
<?php if (!DPCalendarHelper::isFree() && !JFactory::getUser()->guest)
{
?>
[ <a href="<?php echo trim(JUri::base(), '/') . '/components/com_dpcalendar/caldav.php/calendars/' . JFactory::getUser()->username . '/dp-' . $calendar->id?>">
<?php echo JText::_('COM_DPCALENDAR_VIEW_PROFILE_TABLE_CALDAV_URL_LABEL')?>
</a> ]
<?php
}
}
?>

Displaying All Data from Custom Post Type Fields through Advanced Custom Fields

I have looked all over Google, trying to figure this out. I've made some progress but still stuck. I'm pretty new to ACF and custom post types. I have a custom post type of Attorneys that I setup through WCK. That post type has a field group with field names of attorney_photo, attorney_name and attorney_areas_of_practice. With the code below, I can get the attorney_name and attorney_areas_of_practice (repeater field) to display, but not the attorney_photo. I have the info displaying correctly on each attorneys specific page, but I need this page to be a listing of all the attorneys. Not sure what I am doing wrong with the image part.
<?php get_header(); ?>
<?php
$args = array(
'posts_per_page' => 30,
'order' => 'ASC',
'orderby' => 'title',
'post_type' => 'attorneys'
);
query_posts($args);
if ( have_posts() ) :
?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="attorney-preview">
<?php $photo = get_post_meta($post->ID,'attorney_photo', true); ?>
<img src="<?php echo $photo; ?>" />
<p><strong><?php echo get_post_meta($post->ID,'attorney_name', true); ?></strong></p>
<ul>
<?php
while ( have_rows('attorney_areas_of_practice') ) : the_row();
$attorney_area_of_practice = get_sub_field('attorney_area_of_practice');
echo "<li>" . $attorney_area_of_practice . "</li>";
endwhile;
?>
</ul>
</div><!-- .attorney-preview -->
<?php endwhile; ?>
<?php endif; ?>
<?php
wp_reset_query(); // Restore global post data stomped by the_post().
?>
<?php get_footer(); ?>
When you add image field through ACF plugin there are some options of return value. For example return value is: image object or return value is: image url, in your case return value might be selected as image object, not image url. That is why here with your code is being returned an array rather than only url. To get only image url from this array, please write as following a bit change:
<?php $photo = get_post_meta($post->ID,'attorney_photo', true); ?>
<img src="<?php echo $photo['url']; ?>" />
Try this
<?php query_posts(array('posts_per_page' => 30,'order' => 'ASC','orderby' => 'title','post_type' => 'attorneys'));
if (have_posts()) : while (have_posts()) : the_post();
$attorney_photo = get_post_meta($post->ID, 'attorney_photo', true);
$attorney_name = get_post_meta($post->ID, 'attorney_name', true); ?>
<div class="attorney-preview">
<img src="<?php echo $attorney_photo; ?>" />
<p><strong><?php echo $attorney_name; ?></strong></p>
<ul>
<?php
while ( have_rows('attorney_areas_of_practice') ) : the_row();
$attorney_area_of_practice = get_sub_field('attorney_area_of_practice');
echo "<li>" . $attorney_area_of_practice . "</li>";
endwhile;
?>
</ul>
</div><!-- .attorney-preview -->
<?php endwhile; endif; ?>
<?php
wp_reset_query(); // Restore global post data stomped by the_post().
?>

disable layout for particular pages in ZF2

How to disable particular layout(example:menus.phtml) for particular pages in controller in ZF2?? In the below example menus.phtml should be disable for specific pages. Remaining pages must contain menus.phtml like header and footer.
<div>
header.phtml
</div>
<div>
menus.phtml
</div>
<div>
<?php echo $this->content; ?>
</div>
<div>
footer.phtml
</div>
There are various aproaches to this. Also modules.zendframework has quite a few modules here that may help you out.
If you are still keen on writing that yourself you could add variables to your layout within your controllers like so:
<?php
//YourController.php
public function someAction()
{
...
$this->layout()->footer = 'default';
...
}
//layout.phtml
<?php if ($this->footer === 'default') : ?>
//show the footer
<?php endif; ?>
Doing this is pretty inefficient though. Just imagine you'd need to do this to every action in all the controllers... I sure would not like to do that.
Now zf2 has a service and event layer that could help us out quite a bit here. This is a pretty nice read and introduction to it. You'd just write a service and trigger a event on your controllers/routes/whatever. Now you would also probably like to configure what is shown and what is hidden right? Thats pretty easy, too. Just write yourself a config file and merge it with the global.config like so:
<?php
//CustomModule/module.php
public function getConfig() {
$config = array();
$configFiles = array(
include __DIR__ . '/config/module.config.php',
include __DIR__ . '/config/module.customconfig.php',
);
foreach ($configFiles as $file) {
$config = \Zend\Stdlib\ArrayUtils::merge($config, $file);
}
return $config;
}
Source: Where to put custom settings in Zend Framework 2?
First, get the controller or action name:
$controllerName =$this->params('controller');
$actionName = $this->params('action');
then in your layout/view script add a simple logic.
<?php if ($actionName != 'action that you want to disable the layout/menu'): ?>
echo $this->render('menus.phtml');
<?php endif; ?>

PHPExcel reading xls file, get cell styling (font-weight, color, etc)

I am trying to read an excel file and render it as a html table. I would like to get the style that has been applied in excel to a cell and render it in html as well. For example, some cells may have text in BOLD, how do I get that information and use it in the most efficient way?
This is the code I have so far (I am trying out PHPExcel the first time so I am eager to hear any comments or improvements I can make to this):
if ($_GET["xls"]) {
require_once("classes/PHPExcel.php");
$objPHPExcel = PHPExcel_IOFactory::load( dirname(__FILE__) . "/demo.xls" );
$sheetData = $objPHPExcel->getSheetByName('Sheet1')->toArray(null,true,true,true);
?>
<?php if ( count($sheetData) < 0) : ?>
<table class="table striped">
<?php foreach( $sheetData as $y => $row ) : ?>
<tr>
<?php foreach ( $row as $x => $cell) : ?>
<?php if ( $x === "A" ) : ?>
<th><?php echo $cell; ?></th>
<?php else : ?>
<td><?php echo $cell; ?></td>
<?php endif; ?>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<?php
}
Why not take a look at PHPExcel's existing HTML Writer: that already handles merged cells, cell formatting (including borders), font styles, etc.
It seems that the following code works:
$objPHPExcel->getSheetByName('Sheet1')->getStyle("B13")->getFont()->getBold()

Resources