Twig to tpl conversion of {{ ' | ' ~ author }} [closed] - opencart

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
{% if theme_option_status[store_id] %}
{% if header_tag[store_id].font_family == header_tag[store_id].font_family %}
{{ a_tag[store_id].color ? 'a { color: #' ~ a_tag[store_id].color ~ '; }' : '' }}
{{ a_tag[store_id].hover_color ? 'a:hover { color: #' ~ a_tag[store_id].hover_color ~ '; }' : '' }}
{{ total.title ~ " :" }}
{{ article.date_added_d ~ ' ' ~ article.date_added_m ~ ' ' ~ article.date_added_y }}
{% if (count % rows == 0) or (count == articles|length ) %}
{{ (i % 2 == 0) ? 'even' : 'odd' }}
{{ " | " ~ article.author }}
{{ ' | ' ~ author }}
This is the twig file code. How can we write this code in tpl file? I am converting OpenCart 3.0.2.0 theme into OpenCart 2.3.0.2. I am facing problem to covert these difficult lines into tpl PHP line. I have done all other code very well, but I couldn't manage to do these lines of code. How can I convert this line in tpl exactly?

if ($theme_option_status['store_id']) {
if ($header_tag['store_id']['font_family'] == $header_tag['store_id']['font_family']){
echo $a_tag['store_id']['color'] ? 'a { color: #' . $a_tag['store_id']['color'] . '; }' : '';
echo $a_tag['store_id']['hover_color'] ? 'a:hover { color: #' . $a_tag['store_id']['hover_color'] . '; }' : '';
echo $total['title'] . " :" ;
echo $article['date_added_d'] . ' ' . $article['date_added_m'] . ' ' . $article['date_added_y'];
if (($count % $rows == 0) || $count == strlen($articles)) {
echo ($i % 2 == 0) ? 'even' : 'odd' ;
echo " | " . $article['author'];
echo ' | ' . $author;

Related

Custom Repeater Template code in Ajax Load More plugin not compatible with PHP8

We are hosted by WP Engine, so I tested our dev site's compatibility with PHP8 to comply with the upcoming requirement, and ran into a problem. We have listing pages that are automatically generated using a custom coded repeater template within the Wordpress Ajax Load More plugin, in conjunction with ACF. I've picked through it line by line, but can't figure out what's causing the pages to break.
At first, when I tested PHP8 compatibility earlier this year, the repeater pages returned a fatal error. Now I get a partial listing on some, and just a Load More button on others, and the Load More button doesn't work in any instance.
Everything works just fine with PHP 7.4, FWIW.
Here is one of our listing pages for reference:
https://smartorg.com/resources/principles-strategic-portfolio-management/
Here is the custom code:
<?php
$article_link = get_permalink( $post->ID );
$article_time = get_post_meta(get_the_ID(), 'length', TRUE);
$article_time = str_replace( array("min"), '', $article_time);
$article_type = get_post_meta(get_the_ID(), 'type', TRUE);
$article_val = '';
$timer = 'min';
if($article_type == 'Article') {
$article_val = 'read';
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$Words = str_replace(' ', $word_count);
$readingtime = ceil($word_count / 280);
$timer = " min";
$totalreadingtime = $readingtime . $timer;
$article_time = $totalreadingtime;
} else if($article_type == 'Video') {
$article_val = $timer . ' watch';
} else if($article_type == 'Webinar') {
$article_val = $timer . ' watch';
} else if($article_type == 'Audio') {
$article_val = $timer . ' listen';
} else{
$article_val = '';
}
$category = get_the_category( $post->ID );
// echo $atts['is_archive'];
$yoast_meta = get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true);
if ($yoast_meta) {
$meta = $yoast_meta;
} else{
$meta = '';
}
?>
<div class="pm-main-cont">
<div class="pm-col-1">
<div class="pm-red-box"></div>
<div class="pm-article-img">
<a href="<?php echo $article_link; ?>">
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<img src='<?php echo $image[0]; ?>' alt="post thumbnail" />
</a>
</div>
</div>
<div class="pm-col-2">
<div class="pm-article-content">
<h5><?php echo the_title(); ?></h5>
<!-- <p><?php echo the_excerpt(); ?></p> -->
<p><?php echo $meta; ?></p>
<p class="pm-time-type"><img src="http://smartorg.com/wp-content/uploads/2020/09/<?php echo $article_type; ?>.png" alt="<?php echo $article_type; ?>-icon" />
<span><?php
echo $article_time; ?>
<?php echo $article_val; ?>
</span></p>
</div>
</div>
</div>

How change product name in admin orders prestashop

I have problem with old prestashop.
Wants to do to the name of the product is in the form of a list
attribute
br
attribute
br
...
<td><a href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
<span class="productName">'.$product['product_name'].'</span><br />
'.($product['product_reference'] ? $this->l('Ref:').' '.$product['product_reference'] : '')
.(($product['product_reference'] AND $product['product_supplier_reference']) ? ' / '.$product['product_supplier_reference'] : '')
.'</a></td>
Put this code at the top of your file :
$product_name = $product['product_name']
$pos = strpos($product_name, ' - ');
if($pos !== false) {
$product_name = substr_replace($product_name, '<br />', $pos, 3);
}
$product_name = str_replace(', ', '<br />', $product_name);
We replace the first ' - ' and each ', ' by a <br /> so each attributes are on a single line.
Then you can use $product_name instead of $product['product_name'] in your code :
<td><a href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
<span class="productName">'.$product_name.'</span><br />
'.($product['product_reference'] ? $this->l('Ref:').' '.$product['product_reference'] : '')
.(($product['product_reference'] AND $product['product_supplier_reference']) ? ' / '.$product['product_supplier_reference'] : '')
.'</a></td>

adding dropdown to joomla registration

I am want to add a dropdown to joomla 2.5 registration.I believe I can use sql form field type but I want that sql to return all schools of a particular city ( which is in registration form) .So question is how a sql query will accept a parameter?
You have to create one field type in the models==>fields.
for ex: create a php file as schools.php, and then include the following code.
==> schools.php(filename)
defined('JPATH_BASE') or die;
class JFormFieldSchools extends JFormField
{
protected $type = 'Schools';
protected function getInput()
{
// Initialize variables.
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
// Get some field values from the form.
$contactId = (int) $this->form->getValue('id');
$categoryId = (int) $this->form->getValue('catid');
// Build the query for the ordering list.
$query = 'SELECT ordering AS value, name AS text' .
' FROM #__contact_details' .
' WHERE catid = ' . (int) $categoryId .
' ORDER BY ordering';
// Create a read-only list (no name) with a hidden input to store the value.
if ((string) $this->element['readonly'] == 'true') {
$html[] = JHtml::_('list.ordering', '', $query, trim($attr), $this->value, $contactId ? 0 : 1);
$html[] = '<input type="hidden" name="'.$this->name.'" value="'.$this->value.'"/>';
}
// Create a regular list.
else {
$html[] = JHtml::_('list.ordering', $this->name, $query, trim($attr), $this->value, $contactId ? 0 : 1);
}
return implode($html);
}
}
Then you have to change the mysql query as your needs.
If have to change on the default joomla registration page then have following path(.../com_users/models/forms/registration.xml ).
<field name="xxxxx" type="Schools"
description="COM_USERS_REGISTER_NAME_DESC"
filter="string"
label="COM_USERS_REGISTER_NAME_LABEL"
message="COM_USERS_REGISTER_NAME_MESSAGE"
required="true"
size="30" />

Cannot add role="navigation" to wp_nav_menu()

I would like my custom nav menu to have an attribute "role" with value of "navigation". It does not appear that wp_nav_menu() accepts an attributes argument. Am I missing something?
<nav role="navigation">...</nav>
Was looking for a while but then saw that you can set 'container' to false.
<nav role="navigation">
<?php
$defaults = array(
'container' => false,
'items_wrap' => '<ul>%3$s</ul>'
);
wp_nav_menu( $defaults );
?>
</nav>
Returns a simple navigation without divs in the middle.
A little late, but here is how to do it:
<?php
echo strip_tags( wp_nav_menu( array(
'echo' => false,
'items_wrap' => '<nav role="navigation">%3$s</nav>',
) ), '<a><nav>' );
?>
Here's my way to do these:
add_filter( 'wp_nav_menu', function( $nav_menu, $args ) {
if( 'primary' != $args->theme_location || 'nav' != $args->container )
return $nav_menu;
$class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-'. $menu->slug .'-container"';
$id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : '';
$search = '<'. $args->container . $id . $class . '>';
$replace = '<'. $args->container . $id . $class . ' role="navigation">';
return str_replace( $search, $replace, $nav_menu );
}, 10, 2 );

Showing Up of Product Options on Products List

how to show product options on product list in xcart 4.4.2.Under the Men's Clothes category, in shirts, I need to show options like color,size on shirts list itself.Now currently it is in shirt details page.Can anybody help me please.
You can try this solution. This will display all options values for each products in categories specified by category IDs in array(246, 247) in the condition. You should replace it with your own category IDs (home.php?cat=XXX, XXX - it's a category ID)
Patch for products.php
## -133,6 +133,14 ##
}
+if (isset($cat) && in_array($cat, array(246, 247)) && isset($products) && !empty($active_modules['Product_Options'])) {
+ foreach ($products as $k => $v) {
+ if ('Y' == $v['is_product_options']) {
+ $products[$k]['options'] = func_get_product_classes($v['productid']);
+ }
+ }
+}
+
$smarty->assign('cat_products', isset($products) ? $products : array());
$smarty->assign('navigation_script', "home.php?cat=$cat&sort=$sort&sort_direction=$sort_direction");
?>
Patch for skin/common_files/customer/main/products_list.tpl
## -45,6 +45,10 ##
<div class="descr">{$product.descr}</div>
+ {if $active_modules.Product_Options ne ""}
+ {include file="modules/Product_Options/show_options.tpl" product_options=$product.options}
+ {/if}
+
{if $product.rating_data}
{include file="modules/Customer_Reviews/vote_bar.tpl" rating=$product.rating_data productid=$product.productid}
{/if}
skin/common_files/modules/Product_Options/show_options.tpl
{if $product_options ne ''}
<br />
{foreach from=$product_options item=v}
{if $v.options ne ''}
{$v.class|escape}:
{foreach from=$v.options item=o}
{$o.option_name|escape},
{/foreach}
{/if}
<br />
{/foreach}
{/if}