Graham
Waplocus And just how am I supposed to know either
Waplocus
Graham Please graham, i have a file name "fb_glue" how can i remove the underscore using the below code?...
<!--parser:xtscript-->
var $path=<xt:url type="path">
var $pos = call strrpos $haystack=$path; $needle=/
var $name = call substr $val=$path; $start=($pos+1)
print $name
<!--/parser:xtscript-->
Copy code
Graham
Waplocus You need to create a variable to hold the space used to replace the _
<!--parser:xtscript-->
var $spc=call chr $val=32
var $path=<xt:url type="path">
var $pos = call strrpos $haystack=$path; $needle=/
var $name = call substr $val=$path; $start=($pos+1)
var $name = call str_replace $subject=$name; $search=_ ; $replace=$spc
print $name
<!--/parser:xtscript-->
Copy code
Waplocus
Graham Please i have a css file.
e.g
http://site.cf/aaa.css,
how can i print the size on a page?...
Graham
Waplocus use a filelist with the name of the file as the filter so it only shows 1 file
<xt:filelist folder="/folder" filter="aaa.css" template="<a href=".file_url.">.file_name_base_parsed.</a> (.file_size.)<br />"
Copy code
hacklord
Waplocus <!--parser:xtscript-->
var $sharer=<xt:url noquery="1" />
var $file_type=http://xtgem.com/images/icons/mimes
get_or_default __filelist_page;1
get detail
if $detail
goto @landing_page
endif
var $template=<table border="0" width="100%" cellspacing="1"><tbody><tr valign="top"><td width="16px" class="icon"><img src="http://xtgem.com/images/icons/mimes/.file_type..png" alt="*" /></td><td width="auto" class="title"><b><a href="?detail=.file_name.&__filelist_page=1">.file_name_parsed.</a></b></td></tr><tr valign="top"><td colspan="2" class="list1">Size file: .file_size.<br>Date file: .file_date.</td></tr></tbody></table>
var $template=call htmlspecialchars $val=$template
var $list =<xt:filelist sort_type="name" sort_dir="asc" folder="/folder" template="$template" per_page="5" filter="*.*"/>
print $list
print <div class="jump"><form action="" method="get"><input type="text" name="__filelist_page" format="*N" value="" size="3" /><input type="submit" value="Jump Page" class="button" /></form></div>
goto @end
@landing_page
# landing page
# Template must be all on one line
var $query_url = call urlencode $val=$detail
var $template_detail=<div class="title"><img src="$file_type/.file_type..png" alt="*" /> <b>.file_name_parsed.</b></div><div class="list1"><div class="subtitle"><img src="http://kubang.mobie.in/images/download_package.png" class="list1" alt="*" /></div>Type File: .file_mime.<br />Date Update: .file_datetime.</div><div class="list2"><img src="http://kubang.mobie.in/images/icons/download.png" alt="*" /> <b><a href=".file_url.?__xt_download=1">Download File</a></b> (.file_size.)</div><div class="title"><b>Share Link</b></div><div class="list1">Social share: <a href="http://facebook.com/sharer.php?u=$sharer?detail=$query_url"><img src="http://kubang.mobie.in/images/icons/facebook.png" alt="*" /></a> <a href="http://twitter.com/share?url=$sharer?detail=$query_url"><img src="http://kubang.mobie.in/images/icons/twitter.png" alt="*" /></a> <a href="http://plus.google.com/share?url=$sharer?detail=$query_url"><img src="http://kubang.mobie.in/images/icons/google_plus.png" alt="*" /></a></div><div class="list1">File Address:<br><input type="text" value="$sharer?detail=$query_url" /><br>BB Code:<br><input type="text" value="[url=$sharer?detail=$query_url].file_name_parsed. (.file_size.)[/url]" /> <br>HTML Code:<br><input type="text" value="<a href=&quot;$sharer?detail=$query_url&quot;>.file_name_parsed. (.file_size.)</a>" /></div>
var $template_detail=call htmlspecialchars $val=$template_detail
var $list=<xt:filelist folder="/folder" template="$template_detail" filter="$detail"/>
print $list
print <div class="list2">« <a href="?__filelist_page=$__filelist_page"/>Back to list</a></div>
endif
@end
<!--/parser:xtscript-->
Waplocus
hacklord please sir graham help me implement this code...
<!--parser:xtscript-->
var $type = <xt:get_device_template />
if $type == mobile
print <xt:include file="/EXT/Mobile" />
elseif $type == touch
print <xt:include file="/EXT/Touch" />
elseif $type == web
print <xt:include file="/EXT/Web" />
else
print <xt:include file="/EXT/Gen" />
endif
<!--/parser:xtscript-->
Copy code
Graham
Waplocus There are 2 main problems here plus a load of weird little ones
first xt:get_device_template only returns web or mobile it no longer returns touch
There is a workaround hack using the blog and a custom twig file to return the value of data.device from the blog data and that does detect 'touch' devices
The other main issue is xt:includes and their 'parsing order'
in a line like
print <xt:include file="/EXT/Web" /> the issue is that the includes are parsed BEFORE the xtscript so it tries to include the contents of the file into the xtscript before the script itself is parsed and that breaks the script
it breaks because the first line of the included file replaces the xt:include in the script and the rest is included below it so it 'prints' that first line but the rest fails (unless it is xtscript codes)
you can get it to work using
print {{<xt:include file="/EXT/Web" />}} but the file being included cannot contain any other xtscripts because the include is not performed until after the xtscript has finished
you could use the xtscript include but then the file being included must be a .xt xtscript file and written in xtscript syntax
the workaround for get_device template using the blog is this
rename your current xtblog.twig to blog.twig
create a new xtblog.twig file and set this code in it
{% if 'device' in data.translations.t_no_entries_found%}
{{data.device}}
{%else%}
{%include 'blog.twig'%}
{%endif%}
Copy code
you then use
<xt:blog t_no_entries_found="device" /> instead of
<xt:get_device_template />
Waplocus
Graham Wot i'm tryin to do print a css file when the use visit with a mobile and that of javascript.