Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Как записать несколько изображений


Recommended Posts

Здравствуйте.

Пыиюсь сгделать добавление нескольких изображений в блоге.

На данный момент записывается только первая картинка. Помогите советом.

В  могделе

Спойлер
if (isset($data['oct_locations'])) {
			foreach ($data['oct_locations'] as $location) {
				$this->db->query("
					INSERT INTO `" . DB_PREFIX . "oct_bloglocation`
					SET
			            blogarticle_id = '" . (int)$blogarticle_id . "',			            
			            description = '" . $this->db->escape(json_encode($location['description'], true))  . "',
			            image = '" .  $this->db->escape($location['image']) . "',			            
			            sort = '" . (int)$location['sort'] . "'
		        ");

				$oct_location_id = $this->db->getLastId();

				foreach ($location['oct_bloglocation_image'] as $language_id => $oct_bloglocation_image) {
					$this->db->query("
			            INSERT INTO `" . DB_PREFIX . "oct_bloglocation_image`
			            SET
							oct_location_id = '" . (int)$oct_location_id . "',
							language_id = '" . (int)$language_id . "',
							blogarticle_id = '" . (int)$blogarticle_id . "',
						   	image = '" .  $this->db->escape($oct_bloglocation_image['image']) . "',						
							button2 = '" .  $this->db->escape($oct_bloglocation_image['button2']) . "'
					");
				}
			}
		}

 

В контроллере

Спойлер
if (isset($this->request->post['oct_locations'])) {
			$data['oct_locations'] = $this->request->post['oct_locations'];
		} elseif (isset($this->request->get['blogarticle_id'])) {
			$data['oct_locations'] = $this->model_octemplates_blog_oct_blogarticle->getOCTLocations($this->request->get['blogarticle_id']);
		 } else {
			$data['oct_locations'] = [];
		}

 

В твиге

Спойлер
<table id="imagess" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<td class="text-left">{{ entry_additional_image }}</td>
											<td class="text-right">{{ entry_sort_order }}</td>
											<td></td>
										</tr>
									</thead>
									<tbody>
										{% set images_row = 0 %}
										<tr id="image-row{{ images_row }}">
											<td class="text-left">
											<a href="" id="thumb-image{{ images_row }}" data-toggle="image" class="img-thumbnail">
											<img src="{{ oct_location.oct_bloglocation_image.thumb }}" alt="" title="" data-placeholder="{{ placeholder }}" /></a>
											<input type="hidden" name="oct_locations[{{ location_id }}][oct_bloglocation_image][{{ language.language_id }}][image]" value="{{ oct_location.oct_bloglocation_image.image }}" id="input-image{{ images_row }}" />
											</td>
											<td class="text-left"><button type="button" onclick="$('#image-row{{ images_row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
										</tr>
										{% set images_row = images_row + 1 %}
									</tbody>
									<tfoot>
										<tr>
											<td colspan="2"></td>
											<td class="text-left"><button type="button" onclick="addImages();" data-toggle="tooltip" title="{{ button_image_add }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
										</tr>
									</tfoot>
								</table>

 

 

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.