I am working on e-commerce store in Magento and about to finish my work. I want to optimize my code its size/time complexity. In my product view there are 4 different sliders one of then include another 4 subslider. For example if slider3.phtml
which call another sliders depends on some category id.
Here is code-
if ($result == '26') {
echo $this->getLayout()->createBlock('catalog/product_view')->setTemplate('slider/themes.phtml')->toHtml();
}
if ($result == '27') {
echo $this->getLayout()->createBlock('catalog/product_view')->setTemplate('slider/collabs.phtml')->toHtml();
}
.
.
And same for two more sliders.
The slider which I called in if
code block(theme.phtml/collabs.phtml/etc) includes same repeated code only one change is there of category id-. And the code is more than 300 lines.
I want to know if this is fine? or do I need to call it with function? means I will create only one phtml file and create function which call this file with parameter i.e category id.
Or there is no need to do any thing with the code, because code is absolutely working fine. This will affect time complexity of my store?
Please explain me. thanks in advance.