Post by Giraffe » Tue Dec 09, 2008 11:46 pm

Hi i've just added extension to opencart with special products featured products v1.1 and i run into a problem
I've noticed that code in layout.tpl says:

Code: Select all

<?php if ($_REQUEST['controller'] == 'home') { ?>
	<?php if (isset($featured)) { ?> 
	<?php echo $featured; ?>
	<?php } ?>
I deleted one for specials and so on i just want that one to show, and when i enter to the shop with cache cleared from the browser it displays me that there is undefined controller on that line which will be right as this conditional only works when button home is pressed and defines the controller. How i add exception that if controller not define for this bit to show featured products ....
am I missing something???
Last edited by Giraffe on Wed Dec 10, 2008 12:57 am, edited 1 time in total.

User avatar
New member

Posts

Joined
Tue Dec 09, 2008 4:40 am

Post by Qphoria » Tue Dec 09, 2008 11:57 pm

Giraffe wrote:

Code: Select all

<?php if ($_REQUEST['controller'] == 'home') { ?>
	<?php if (isset($featured)) { ?> 
	<?php echo $featured; ?>
	<?php } ?>
you need to close the first if statement

Code: Select all

<?php if ($_REQUEST['controller'] == 'home') { ?>
	<?php if (isset($featured)) { ?> 
	<?php echo $featured; ?>
	<?php } ?>
<?php } ?>

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Giraffe » Tue Dec 09, 2008 11:59 pm

Yes it is closed i forgot to paste it properly...

I suspect that maybe i should load this controller in home.php before template file loads?
sorry for all this questions i am fairly new to php ... :)

User avatar
New member

Posts

Joined
Tue Dec 09, 2008 4:40 am

Post by Qphoria » Wed Dec 10, 2008 12:03 am

So to clarify, you installed the "Latest/Featured/Specials Homepage" contrib and you are seeing invalid controller messages for things. I only remember trying to use that contrib once, and I wasn't successful based on the included instructions. I haven't played with it since then, but maybe the original author can help.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Giraffe » Wed Dec 10, 2008 12:20 am

That's right and it works quite ok as long as someone presses on home button then url changes to
http://192.168.0.1/shop/index.php?controller=home

and when someone enters to the page in my instance i type ip of my server and then it says controller undefined if I then remove first if statement and change code to:

Code: Select all

<?php if (isset($featured)) { ?> 
	<?php echo $featured; ?>
	<?php } ?>
then featured products list displays on every single page as it is hardcoded into layout i guess.
I am wondering how to construct this script in the situation if :
a)customer entered webpage then featured products are displayed
b)customer pressed on a home button  and then featured products are displayed
but they are not being displayed when i am in different parts of the shop.
Last edited by Giraffe on Wed Dec 10, 2008 12:23 am, edited 1 time in total.

User avatar
New member

Posts

Joined
Tue Dec 09, 2008 4:40 am

Post by Qphoria » Wed Dec 10, 2008 12:31 am

Ah i see.
What about:

Code: Select all

<?php if ($_REQUEST['controller'] == 'home' || $_REQUEST['controller'] == '') { ?>
	<?php if (isset($featured)) { ?> 
	<?php echo $featured; ?>
	<?php } ?>
<?php } ?>

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Giraffe » Wed Dec 10, 2008 12:53 am

Ohh yes the || logical operator .. I was planing to use it as well

Now i get it double then when i press home then it is ok.
Message i am getting is:
Notice: Undefined index: controller in C:\wamp\www\shop\catalog\template\default\layout.tpl on line 45
Notice: Undefined index: controller in C:\wamp\www\shop\catalog\template\default\layout.tpl on line 45

I think it is because request checks if controller value has been passed through url...
and when customer enters shop for the first time then request is not yet triggered....

maybe there is different way of achieving this?
Last edited by Giraffe on Wed Dec 10, 2008 12:59 am, edited 1 time in total.

User avatar
New member

Posts

Joined
Tue Dec 09, 2008 4:40 am

Post by Qphoria » Wed Dec 10, 2008 12:59 am

hmm.. an ugly way to try

Code: Select all

<?php if (@$_REQUEST['controller']) { ?>
	<?php if ($_REQUEST['controller'] == 'home' || $_REQUEST['controller'] == '') { ?>
		<?php if (isset($featured)) { ?> 
		<?php echo $featured; ?>
		<?php } ?>
	<?php } ?>
<?php } else {?>
	<?php if (isset($featured)) { ?> 
	<?php echo $featured; ?>
	<?php } ?>
<?php } ?>

Last edited by Qphoria on Wed Dec 10, 2008 1:01 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Giraffe » Wed Dec 10, 2008 1:07 am

no luck  ???

Parse error: syntax error, unexpected $end in C:\wamp\www\shop\catalog\template\default\layout.tpl on line 66

i check this line and it is end of file ok code look like this at the moment...

Code: Select all

<div id="content"><?php echo $content; ?>
<?php if (@$_REQUEST['controller']) { ?>
<?php if ($_REQUEST['controller'] == 'home' || $_REQUEST['controller'] == '') { ?>
	<?php if (isset($featured)) { ?> 
	<?php echo $featured; ?>
	<?php } ?>
<?php } else {?>
	<?php if (isset($featured)) { ?> 
	<?php echo $featured; ?>
	<?php } ?>
<?php } ?>
  </div>
  <?php } ?>
  <?php if (isset($footer)) { ?>
  <div id="footer"><?php echo $footer; ?></div>
  <?php } ?>
</div>
<?php if (isset($time)) { ?>
<div id="time"><?php echo $time; ?></div>
<?php } ?>
</body>
</html>

User avatar
New member

Posts

Joined
Tue Dec 09, 2008 4:40 am

Post by Qphoria » Wed Dec 10, 2008 1:25 am

take a look at my code above again... i edited it to fix that right after I posted it, you just got it too fast.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Giraffe » Wed Dec 10, 2008 1:38 am

Yep! it works now the featured products appear now only on a home page.
What the @ before request stands for?

Oh a little bit off topic but my wife was asking me for that... :)

Are you going to be so kind to share the secret how did you managed
to be blessed with triplets special diet or pure luck ???

User avatar
New member

Posts

Joined
Tue Dec 09, 2008 4:40 am

Post by Qphoria » Wed Dec 10, 2008 2:22 am

@ means to suppress the error if it doesn't exist

Triplets: Pure luck I think. We have no history in our families, not even twins.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jty » Wed Dec 10, 2008 11:09 pm

Giraffe wrote: Are you going to be so kind to share the secret how did you managed
to be blessed with triplets special diet or pure luck ???
It was duplicate code
He did the cut 'n paste trick and accidentally ended up with triplicate code  :P

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Thu Dec 11, 2008 2:48 am

;D

Btw, I've Updated the Latest/Featured/Specials contrib to work with 0.7.9:
You can get it here: http://forum.opencart.com/index.php/topic,2446.0.html

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 3 guests