Opencart ...unexpected '}'

OpenCart WordPress Joomla Mambo IPB E107 и т.н.
mesm
Нов
Нов
Posts: 25
Joined: Tue Apr 27, 2010 1:38 pm
Location: Варна
Contact:

Opencart ...unexpected '}'

Post by mesm » Tue May 31, 2016 9:52 am

Моля помогнете ми с тази грешка..

Parse error: syntax error, unexpected '}' in .... common_header.tpl on line 228

Code: Select all

<?php if &#40;$categories&#41; &#123; ?>
      <div id="menu">
		<ul>
		  <li><a class="home" href="<?php echo $home; ?>"></a></li>
		  <?php if &#40;$all_news_top_menu == 'top_left'&#41; &#123; ?>
			<li><a href="<?php echo $all_news; ?>"><?php echo $text_all_news; ?></a></li>
		  <?php &#125; ?>
		  <?php foreach &#40;$categories as $category&#41; &#123; ?>
			<li class="dropdown"><a href="<?php echo $category&#91;'href'&#93;; ?>"><?php echo $category&#91;'name'&#93;; ?></a>
			<div><?php if &#40;$category&#91;'children'&#93;&#41; &#123; ?>
			  <div class="dropdown-block">
				<?php for &#40;$i = 0; $i < count&#40;$category&#91;'children'&#93;&#41;;&#41; &#123; ?>
				  <ul>
					<?php $j = $i + ceil&#40;count&#40;$category&#91;'children'&#93;&#41; / $category&#91;'column'&#93;&#41;; ?>
					<?php for &#40;; $i < $j; $i++&#41; &#123; ?>
					  <?php if &#40;isset&#40;$category&#91;'children'&#93;&#91;$i&#93;&#41;&#41; &#123; 
						$desc = trim&#40;preg_replace&#40;'/\s\s+/', ' ',$category&#91;'children'&#93;&#91;$i&#93;&#91;'description'&#93; &#41;&#41;;
						$desc = addslashes&#40;$desc&#41;;?>
						<li onmouseover="changeImage&#40;'<?php if&#40;$category&#91;'children'&#93;&#91;$i&#93;&#91;'image'&#93;&#41; echo 'image/'.$category&#91;'children'&#93;&#91;$i&#93;&#91;'image'&#93;; ?>','bannerHolder_<?php echo $category&#91;'category_id'&#93;;?>','exm_description_<?php echo $category&#91;'category_id'&#93;;?>','<?php echo $desc;?>'&#41;;">
						<a  href="<?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'href'&#93;; ?>">
						<?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'name'&#93;; ?></a></li>
						          <?php &#125; ?>
          <?php &#125; ?>
        </ul>
   
        <?php &#125; ?>
     
      <?php &#125; ?>
	 
              <div class="bannerWrap"><img id="bannerHolder_<?php echo $category&#91;'category_id'&#93;;?>" src="<?php if&#40;$category&#91;'image'&#93;&#41; echo "image/".$category&#91;'image'&#93;;?>"/><div class="exm_description" id="exm_description_<?php echo $category&#91;'category_id'&#93;;?>"><?php echo html_entity_decode&#40;$category&#91;'description'&#93;&#41;;?></div></div>
	 
	</div>
    </li>
    <?php &#125; ?>
  </ul>
</div>
<script>
$&#40;document&#41;.ready&#40;function&#40;&#41; &#123;
$&#40;'#menu ul > li > a + div'&#41;.each&#40;function&#40;index, element&#41; &#123;
    var menu = $&#40;'#menu'&#41;.offset&#40;&#41;;
	var dropdown = $&#40;this&#41;.parent&#40;&#41;.offset&#40;&#41;;
	$&#40;this&#41;.css&#40;'left',menu.left-dropdown.left+5&#41;;
	$&#40;this&#41;.css&#40;'width',$&#40;'#menu'&#41;.outerWidth&#40;&#41;-15&#41;;
	$&#40;this&#41;.css&#40;'margin-left','0px','important'&#41;;
&#125;&#41;;
&#125;&#41;;
</script>
<script>
function changeImage&#40;link,banner,desc_place,desc&#41;&#123;
if&#40;link!=''&#41;document.getElementById&#40;banner&#41;.src=link;	
else document.getElementById&#40;banner&#41;.src="";
	document.getElementById&#40;desc_place&#41;.innerHTML=desc;	
&#125;
</script>
<?php &#125; ?>
						<li class="dropdown-level"> 
						  <?php $levels_2 = $this->model_catalog_category->getCategories&#40;$category&#91;'children'&#93;&#91;$i&#93;&#91;'category_id'&#93;&#41;; ?>
						  <?php if&#40;$levels_2&#41; &#123;  ?>
							<a href="<?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'href'&#93;; ?>"><?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'name'&#93;; ?><span class="parent"></span></a>
							<div class="dropdown-block-level">
							  <ul>
								<?php foreach &#40;$levels_2 as $level_2&#41; &#123; ?>
								  <li><a href="<?php echo $this->url->link&#40;'product/category', 'path='.$category&#91;'category_id'&#93;.'_' . $category&#91;'children'&#93;&#91;$i&#93;&#91;'category_id'&#93; . '_' . $level_2&#91;'category_id'&#93;&#41;; ?>"><?php echo $level_2&#91;'name'&#93;; ?></a></li>	
								<?php &#125; ?>
							  </ul>
							</div>
						  <?php &#125; else &#123; ?>
							<a href="<?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'href'&#93;; ?>"><?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'name'&#93;; ?></a>
						  <?php &#125; ?>
						</li>
					  <?php &#125; ?>
					<?php &#125; ?>
				  </ul>
				<?php &#125; ?>
			  </div>
			<?php &#125; ?>
		    </li>
		  <?php &#125; ?>
		  <?php echo $menu; ?>
		  <?php if &#40;$all_news_top_menu == 'top_right'&#41; &#123; ?>
			<li><a href="<?php echo $all_news; ?>"><?php echo $text_all_news; ?></a></li>
		  <?php &#125; ?>
		</ul>
	  </div>
	<?php &#125; ?>
	<div class="clear"></div>
	<div id="notification"></div>
	<div id="wrapper">
Къде е проблема в този код... :? :(

User avatar
vinsbg
Гуру
Гуру
Posts: 2604
Joined: Wed Jan 28, 2009 12:21 pm
Answers: 51
Location: София
Contact:

Post by vinsbg » Tue May 31, 2016 10:36 am

Някъде имаш една отваряща скоба по-малко най-вероятно...

mesm
Нов
Нов
Posts: 25
Joined: Tue Apr 27, 2010 1:38 pm
Location: Варна
Contact:

Post by mesm » Tue May 31, 2016 11:11 am

Да, това го разбрах, но не мога да разбера къде е... :(
Трябва да е в рамките на този код, но нищо не схващам.. :shock:

Code: Select all

<?php if &#40;isset&#40;$category&#91;'children'&#93;&#91;$i&#93;&#41;&#41; &#123; 
						$desc = trim&#40;preg_replace&#40;'/\s\s+/', ' ',$category&#91;'children'&#93;&#91;$i&#93;&#91;'description'&#93; &#41;&#41;;
						$desc = addslashes&#40;$desc&#41;;?>
						<li onmouseover="changeImage&#40;'<?php if&#40;$category&#91;'children'&#93;&#91;$i&#93;&#91;'image'&#93;&#41; echo 'image/'.$category&#91;'children'&#93;&#91;$i&#93;&#91;'image'&#93;; ?>','bannerHolder_<?php echo $category&#91;'category_id'&#93;;?>','exm_description_<?php echo $category&#91;'category_id'&#93;;?>','<?php echo $desc;?>'&#41;;">
						<a  href="<?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'href'&#93;; ?>">
						<?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'name'&#93;; ?></a></li>
						          <?php &#125; ?>
          <?php &#125; ?>
        </ul>
   
        <?php &#125; ?>
     
      <?php &#125; ?>
	 
              <div class="bannerWrap"><img id="bannerHolder_<?php echo $category&#91;'category_id'&#93;;?>" src="<?php if&#40;$category&#91;'image'&#93;&#41; echo "image/".$category&#91;'image'&#93;;?>"/><div class="exm_description" id="exm_description_<?php echo $category&#91;'category_id'&#93;;?>"><?php echo html_entity_decode&#40;$category&#91;'description'&#93;&#41;;?></div></div>
	 
	</div>
    </li>
    <?php &#125; ?>
  </ul>
</div>
<script>
$&#40;document&#41;.ready&#40;function&#40;&#41; &#123;
$&#40;'#menu ul > li > a + div'&#41;.each&#40;function&#40;index, element&#41; &#123;
    var menu = $&#40;'#menu'&#41;.offset&#40;&#41;;
	var dropdown = $&#40;this&#41;.parent&#40;&#41;.offset&#40;&#41;;
	$&#40;this&#41;.css&#40;'left',menu.left-dropdown.left+5&#41;;
	$&#40;this&#41;.css&#40;'width',$&#40;'#menu'&#41;.outerWidth&#40;&#41;-15&#41;;
	$&#40;this&#41;.css&#40;'margin-left','0px','important'&#41;;
&#125;&#41;;
&#125;&#41;;
</script>
<script>
function changeImage&#40;link,banner,desc_place,desc&#41;&#123;
if&#40;link!=''&#41;document.getElementById&#40;banner&#41;.src=link;	
else document.getElementById&#40;banner&#41;.src="";
	document.getElementById&#40;desc_place&#41;.innerHTML=desc;	
&#125;
</script>
<?php &#125; ?>
                       
						<li class="dropdown-level"> 
						  <?php $levels_2 = $this->model_catalog_category->getCategories&#40;$category&#91;'children'&#93;&#91;$i&#93;&#91;'category_id'&#93;&#41;; ?>
						  <?php if&#40;$levels_2&#41; &#123;  ?>
							<a href="<?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'href'&#93;; ?>"><?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'name'&#93;; ?><span class="parent"></span></a>
							<div class="dropdown-block-level">
							  <ul>
								<?php foreach &#40;$levels_2 as $level_2&#41; &#123; ?>
								  <li><a href="<?php echo $this->url->link&#40;'product/category', 'path='.$category&#91;'category_id'&#93;.'_' . $category&#91;'children'&#93;&#91;$i&#93;&#91;'category_id'&#93; . '_' . $level_2&#91;'category_id'&#93;&#41;; ?>"><?php echo $level_2&#91;'name'&#93;; ?></a></li>	
								<?php &#125; ?>
							  </ul>
							</div>
						  <?php &#125; else &#123; ?>
							<a href="<?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'href'&#93;; ?>"><?php echo $category&#91;'children'&#93;&#91;$i&#93;&#91;'name'&#93;; ?></a>
						  <?php &#125; ?>
						</li>
					  <?php &#125; ?>
					<?php &#125; ?>
				  </ul>
				<?php &#125; ?>
			  </div>
			<?php &#125; ?>
		    </li>
		  <?php &#125; ?>

User avatar
vinsbg
Гуру
Гуру
Posts: 2604
Joined: Wed Jan 28, 2009 12:21 pm
Answers: 51
Location: София
Contact:

Post by vinsbg » Tue May 31, 2016 12:58 pm

Аз тук виждам поне 10 затварящи скоби, но не виждам 10 отварящи..

User avatar
teroristd
Много Редовен
Много Редовен
Posts: 1769
Joined: Thu Feb 18, 2010 11:50 am
Answers: 83

Post by teroristd » Tue May 31, 2016 2:24 pm

Имаш 14 отварящи скоби и 20 затварящи. Сам си направи сметката.

Някой беше казал "Когато започвам да пиша този код, само аз и Господ знаем какво става, когато го завърша вече само Господ знае." :D .

User avatar
anonimen
Много Редовен
Много Редовен
Posts: 1523
Joined: Mon Jun 11, 2012 6:07 pm
Answers: 162
Location: Parse error: unexpected "}" in /home/index.php on line 26

Post by anonimen » Tue May 31, 2016 2:34 pm

Как сте ги броили, бе, хора ;D

Иначе в такова положение имаш три възможности:
1. Минаваш с пръст през целия код и си откриваш грешката (Hard)
2. Пренаписваш си кода. (Medium) (зависи, може 1. и 2. да са разменени)
3. Премахваш отделни самостоятелно независими части и гледаш какво става (Easy)

По 3. - махни поотделно примерно ul-ове и гледай резултата - ако се оправи, значи там някъде е била грешката. Иначе отиваш едно ниво (един таг) нагоре и правиш същото.

User avatar
teroristd
Много Редовен
Много Редовен
Posts: 1769
Joined: Thu Feb 18, 2010 11:50 am
Answers: 83

Post by teroristd » Tue May 31, 2016 2:51 pm

То това не е целия код 100%, аз махнах 6 скоби долу от ли-тата ей така за пробата и ми даде вече други грешки което е нормално.

Notice: Undefined variable: categories in:
Fatal error: Using $this when not in object context in:

Но няма как някой да пропусне толкова скоби :) .

User avatar
vinsbg
Гуру
Гуру
Posts: 2604
Joined: Wed Jan 28, 2009 12:21 pm
Answers: 51
Location: София
Contact:

Post by vinsbg » Tue May 31, 2016 5:28 pm

Сложи целия код в pastebin ако е прекалено дълъг и дай да го видим...

mesm
Нов
Нов
Posts: 25
Joined: Tue Apr 27, 2010 1:38 pm
Location: Варна
Contact:

Post by mesm » Tue May 31, 2016 11:13 pm

Благодаря на всички Ви момчета! :?:
Погнах го това меню...

Сега се боря да изкарам продуктите в менюто с изображения, вместо подкатегорийте.
Ако някой някой е минавал през това и може да помогне, ще съм му много благодарна, защото ще ми спести още един дъъъълъг ден... :idea: :)

Това е сайта: http://www.10plus1.eu/

А това е менюто, което се опитвам да направя: http://demo.abantecart.com/

mesm
Нов
Нов
Posts: 25
Joined: Tue Apr 27, 2010 1:38 pm
Location: Варна
Contact:

Post by mesm » Wed Jun 01, 2016 2:29 am

Оправих се.. :D явно се оказах по умна от очакваното... 8) :D

Усмихнат ден на всички! :?:

Post Reply