Post by randompeople10 » Mon Jan 13, 2020 4:13 pm

Code: Select all

                            {% if categories %}
                                {% for i in categories %}
                                    <option value="{{ i.category_id }}">{{ i.name }}</option>
                                {% endfor %}
                            {% endif %}

Code: Select all

                                            <td class="text-left">
                                                {% if sort == 'pd.name' %}
                                                    <a class="{{ order|lower }}">{{ column_name }}</a>
                                                {% else %}
                                                    <a>{{ column_name }}</a>
                                                {% endif %}
                                            </td>
Any idea that how do i convert the above code to php syntax ? have trouble on converting this code and can't find any explaintion on the web :choke:


Posts

Joined
Mon Jan 13, 2020 4:06 pm

Post by uksitebuilder » Mon Jan 13, 2020 4:29 pm

Code: Select all

<?php if($categories){ ?>
    <?php foreach ($categories as $category){ ?>
        <option value="<?php echo $category['category_id']; ?>"><?php echo $category['name']; ?></option>
    <?php } ?>
<?php } ?>

Code: Select all

<td class="text-left">
    <?php if($sort == 'pd.name'){ ?>
        <a class="<?php echo strtolower($order); ?>"><?php echo $column_name; ?></a>
    <?php } else { ?>
        <a><?php echo $column_name; ?></a>
    <?php } ?>
</td>

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by randompeople10 » Mon Jan 13, 2020 4:50 pm

uksitebuilder wrote:
Mon Jan 13, 2020 4:29 pm

Code: Select all

<?php if($categories){ ?>
    <?php foreach ($categories as $category){ ?>
        <option value="<?php echo $category['category_id']; ?>"><?php echo $category['name']; ?></option>
    <?php } ?>
<?php } ?>

Code: Select all

<td class="text-left">
    <?php if($sort == 'pd.name'){ ?>
        <a class="<?php echo strtolower($order); ?>"><?php echo $column_name; ?></a>
    <?php } else { ?>
        <a><?php echo $column_name; ?></a>
    <?php } ?>
</td>
Thanks

for this

Code: Select all

                                                        {% if i.image %}
                                                            <img src="{{ i.image }}" alt="{{ i.image }}" class="img-thumbnail" />
                                                        {% else %}
                                                            <span class="img-thumbnail list"><i class="fa fa-camera fa-2x"></i></span>
                                                        {% endif %}
after conversion it should turn look like this ?

Code: Select all

<?php if($special){ ?>
  <?php foreach ($special as $specials){ ?>
	<?php if($specials['image']){ ?>
            <img src="<?php $specials['image']?>" alt="<?php echo $specials['image']?>" class="img-thumbnail" />
	else {
	<span class="img-thumbnail list"><i class="fa fa-camera fa-2x"></i></span>
}
<?php } ?>
and how about this ?

Code: Select all

                                                    <td class="text-left">
                                                        {{ i.product_name }}
                                                        <input type="hidden" name="product[{{ list_row }}][product_id]" value="{{ i.product_id }}" data-type="product_id" class="form-control" />
                                                    </td>
everything look weird


Posts

Joined
Mon Jan 13, 2020 4:06 pm

Post by xxvirusxx » Mon Jan 13, 2020 4:58 pm

randompeople10 wrote:
Mon Jan 13, 2020 4:50 pm
and how about this ?

Code: Select all

                                                    <td class="text-left">
                                                        {{ i.product_name }}
                                                        <input type="hidden" name="product[{{ list_row }}][product_id]" value="{{ i.product_id }}" data-type="product_id" class="form-control" />
                                                    </td>
everything look weird

Code: Select all

 <td class="text-left"><?php echo $i['product_name']; ?>
    <input type="hidden" name="product[<?php echo $list_row ; ?>][product_id]" value="<?php echo $i['product_id']; ?>" data-type="product_id" class="form-control" />
   </td>
randompeople10 wrote:
Mon Jan 13, 2020 4:50 pm

Code: Select all

                                                        {% if i.image %}
                                                            <img src="{{ i.image }}" alt="{{ i.image }}" class="img-thumbnail" />
                                                        {% else %}
                                                            <span class="img-thumbnail list"><i class="fa fa-camera fa-2x"></i></span>
                                                        {% endif %}

Code: Select all

<?php if ($i['image']) { ?>
      <img src="<?php echo $i['image']; ?>" alt="<?php echo $i['image']; ?>" class="img-thumbnail" />
<?php } else { ?>
    <span class="img-thumbnail list"><i class="fa fa-camera fa-2x"></i></span>
<?php } ?>

What you want to convert?

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by letxobnav » Tue Jan 14, 2020 2:08 am

Why do you guys keep on opening and closing php with multiple echo statements?

Code: Select all

<?php if ($i['image']) { ?>
      <img src="<?php echo $i['image']; ?>" alt="<?php echo $i['image']; ?>" class="img-thumbnail" />
<?php } else { ?>
    <span class="img-thumbnail list"><i class="fa fa-camera fa-2x"></i></span>
<?php } ?>
Just echo once.

Code: Select all

<?php 
if ($i['image']) {
   echo '<img src="'.$i['image'].'" alt="'.$i['image'].'" class="img-thumbnail" />';
} else {
   echo '<span class="img-thumbnail list"><i class="fa fa-camera fa-2x"></i></span>';
}
?>

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by randompeople10 » Tue Jan 14, 2020 9:50 am

Thanks , the page is working right now after some modify

Code: Select all

    
 <td class="text-left">
      <select name="product[{{ list_row }}][status]" id="input-status" class="form-control">
 	      {% if i.status %}
       		<option value="1" selected="selected">{{ text_enabled }}</option>
		<option value="0">{{ text_disabled }}</option>
             {% else %}
          	 <option value="1">{{ text_enabled }}</option>
         	   <option value="0" selected="selected">{{ text_disabled }}</option>
             {% endif %}
      </select>
</td>
    <td class="text-left">
           <button id="button_cancel" type="button" onclick="$('#product_row_{{ list_row }}').remove()" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger">
      <i class="fa fa-minus-circle"></i>
        </button>
          </td> 
        	 </tr>
       {% set list_row = list_row + 1 %}
        {% endfor %}
        {% endif %}
Can anyone explain on the the last 2 code ? (SET and OPTION VALUE)
the rest able to modify myself.


Posts

Joined
Mon Jan 13, 2020 4:06 pm

Post by by mona » Tue Jan 14, 2020 10:05 am

option value is the value of the option stored in the database as an integer
and set is setting the next row value as + 1 more

https://www.w3schools.com/tags/tag_option.asp
https://twig.symfony.com/doc/3.x/templates.html

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by paulfeakins » Tue Jan 14, 2020 5:57 pm

randompeople10 wrote:
Mon Jan 13, 2020 4:13 pm
Any idea that how do i convert the above code to php syntax ? have trouble on converting this code and can't find any explaintion on the web :choke:
Why not just use Twig?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by xxvirusxx » Wed Jan 15, 2020 1:34 am

letxobnav wrote:
Tue Jan 14, 2020 2:08 am
Why do you guys keep on opening and closing php with multiple echo statements?
We respect opencart code structure :D
randompeople10 wrote:
Tue Jan 14, 2020 9:50 am
Can anyone explain on the the last 2 code ? (SET and OPTION VALUE)

Code: Select all

<?php $list_row  = 0; ?>
<?php $list_row++; ?>

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by letxobnav » Wed Jan 15, 2020 3:09 am

"opencart" and "structure", those two words don't mix.

More difficult to read and creating a lot of white-space.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by paulfeakins » Wed Jan 15, 2020 5:16 pm

letxobnav wrote:
Wed Jan 15, 2020 3:09 am
"opencart" and "structure", those two words don't mix.

More difficult to read and creating a lot of white-space.
I'd strongly disagree, one of the reasons we chose OpenCart originally was that the code is well-written and clean.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 426 guests