Disaru
I MAde a duplicate post in the wrong section ('Tips and code snippet'), but this kind of post should be here, 'Coding help'. Please delete that Moderator, sorry
Here is the code:
<!--parser:xtscript-->
var $num = 0
@loop_start
if $num <= 9
print <a href="" class="random-game-$num"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title w3-text-grey" style="word-break:break-all"></span><div style="clear:both"></div></li></a>
var $num = $num+1
goto @loop_start
endif
<!--/parser:xtscript-->
Copy code
But it's not working and the code markup showing error like this:
<!--parser:xtscript-->
var $num = 0
@loop_start
if $num <
= 9
print <a
href="" class="random-game"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title w3-text-grey" style="word-break:break-all"></span><div style="clear:both"></div></li>
</a>
var $num = $num+1
goto @loop_start
endif
<!--/parser:xtscript-->
Is there something wrong?
Graham
Disaru $num+1 must be in brackets ($num+1) or it gets treated as a string and you get '0+1' in the variable
As for the other the syntax highlighter does not like the < and treats it as an broken html tag error but it does not affect the actual operation of the code
I often start my code with #<? and end with #?> to switch off the highlighter
<!--parser:xtscript-->
#<?
var $num = 0
@loop_start
if $num <= 9
print <a href="" class="random-game"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title w3-text-grey" style="word-break:break-all"></span><div style="clear:both"></div></li></a>
var $num = ($num+1)
goto @loop_start
endif
#?>
<!--/parser:xtscript-->
Copy code
also <li> is only allowed in a <ul> or <ol> tag and your code may not do what you expect
https://www.w3schools.com/html/html_lists.asp
nor should a <div> be inside an <a> tag
Disaru
Graham Thank you, I have corrected my code. But I have new problem now
That code is placed on my "_footer" file to create sidebar menu. But oddly, the code not working only on homepage, but it work on another page. Here (check the Sidebar):
http://gratrik.xtgem.com - Not working, I even check the html source and yes it not printed.
But working and printed on another page:
http://gratrik.xtgem.com/android-game/view/?get=Warp_Runner_APK
http://gratrik.xtgem.com/android-game
Hmm... any idea sir?
Graham
Disaru Thats some complex code and without studying it I honestly have no idea
chrome devtools shows no obvious errors
Disaru
Graham I know it's the xtscript problem, as why it's not printed only on homepage.
Basically using the code I want to create ten elements list with empty attribute, then I use JQuery to fill the attribute.
But now I have no option except changed the xtscript, and do it with old fashioned way like this LOL:
<a href="" class="random-game-0"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
<a href="" class="random-game-1"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
<a href="" class="random-game-2"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
<a href="" class="random-game-3"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
<a href="" class="random-game-4"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
<a href="" class="random-game-5"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
<a href="" class="random-game-6"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
<a href="" class="random-game-7"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
<a href="" class="random-game-8"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
<a href="" class="random-game-9"><li><img src="" class="w3-left thumbnail" width="96" height="96" alt="" /><span class="title" style="word-break:break-all"></span><br style="clear:both" /></li></a>
Copy code
The most important thing that, it worked
:
http://gratrik.xtgem.com
Graham
Disaru well as long as it works that's the main thing the actual amount of code sent to the browser is the same either way