Announcement

Collapse
No announcement yet.

Search Results Page PHP Parse Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Search Results Page PHP Parse Error

    Hi,

    I'm trying to alter the layout of the results our search page generates. We have 4 columns and I need the 4th column to have a different class to the other three.

    Within my Standard Search Results List there is no editing of the lists layout as there is with all the other lists on our site. I assume this is in some part due to the dynamic nature of the results. If this isn't the case and i can add this in please stop me here and let me know how.

    As i have assumed I need to build this layout myself I have added a php block to the Standard Search Results which I want to perform a modulus test against the SearchResultItem variable. If it is divisble by 4 I know it's the final column and I can pop in the different class.

    What i have is therefore:

    Code:
    <actinic:block php="true">
    	if (<actinic:variable name="SearchResultItem" /> % 4 === 0) {
    		echo "<div class=\"sectionProduct section right\">";
    	}
    	else {
    		echo "<div class=\"sectionProduct section left\">";
    	}
    </actinic:block>
    However I am getting a PHP Parse error which occurs whenever i place any of the Search Result variables within the PHP block.

    Can anyone advise on where I am going wrong.

    Kind Reagrds,

    Guy

    Lock Shop Warehouse
    Dedicated to offering a huge range of discounted locks, padlocks & safes
    Regards,

    Guy

    Lead Developer - Lock Shop Warehouse
    Offering discounted padlocks, and a huge range from the best door lock suppliers, all alongside other essential security products.

    #2
    <actinic:variable name="SearchResultItem" /> isn't available when the pages are being generated. It's created on the web-server via SearchScript.pl.

    You'll have to do this some other way (Perl patching probably).
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thanks Norman, I'll move ahead with not working on this problem anymore.....

      Guy
      Regards,

      Guy

      Lead Developer - Lock Shop Warehouse
      Offering discounted padlocks, and a huge range from the best door lock suppliers, all alongside other essential security products.

      Comment


        #4
        JavaScript might work. It would be parsed when the page loads in the browser and by then that variable will be represented by a number.

        Untested:-
        Code:
        <script type="text/javascript">
        	if (<actinic:variable name="SearchResultItem" /> % 4 == 0) {
        		document.write('<div class="sectionProduct section right">');
        	}
        	else {
        		document.write('<div class="sectionProduct section left">');
        	}
        </script>
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          As the code appears inline, it may be worth optimising. Again untested.
          Put this in the top of the results page overall layout:
          Code:
          <script type="text/javascript">
          	function styleit(seq){
          		document.write('<div class="sectionProduct section ' + ((seq % 4 == 0) ? 'right' : 'left')  + '">');
          	}
          </script>
          And use:
          Code:
          <script type="text/javascript">styleit('<actinic:variable name="SearchResultItem" />')</script>
          In each result.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Hi Norman,

            Just saw your replies, I actually did exactly that, when you said i couldn't achieve it in PHP via Actinic I didn't fancy the perl edits so I made a javascript function which does the trick.

            Thank you for your thoughts and help with this...

            Regards,

            Guy
            Regards,

            Guy

            Lead Developer - Lock Shop Warehouse
            Offering discounted padlocks, and a huge range from the best door lock suppliers, all alongside other essential security products.

            Comment

            Working...
            X