Can someone explain to me why we use this instruction {notification} in the code of phpfox? For example in this code we use {notification}:
{if Phpfox::isUser() && !Phpfox::getUserBy('profile_page_id')}
getFullControllerName() == 'appletjava.index'} style="float: right;position: absolute;right: 199px;top: 7px;left:auto;" {/if}>
{notification}
{/if}
We can found other keywords also that use {} I want to know what it means.
all the {something} in phpfox templates get replaced for php code at "compilation" time. To learn what all the possibilities and replacements are open the file /include/library/phpfox/template/cache.class.php
For this specific question you will find it in line 1261 and it gets replaced for:
return '<?php Phpfox::getBlock(\'core.template-notification\'); ?>';
Related
what is the similar blade syntax for the following code?
<?php if(...):?>abc<?php else:?>cde<?php endif;?>
the code
#if(...) abc #else .... is no good as it ads a space before and after the "abc" the code #if(...)abc#endif (no spacing before and after html string) generates error ...
Thanks
Solution
The correct solution for this problem would be following:
#if(1==1){{ '1' }}#endif
This happens often and makes problem with "space sensitive" parts of code like values in <option> tags.
Having the #if(1==1) 1 #endif would be compiled to following which shows empty spaces around the number:
<?php if(1==1): ?> 1 <?php endif; ?>
Solution code would be compiled to this code:
<?php if(1==1): ?><?php echo e('1'); ?><?php endif; ?>
Which pretty much explains why this won't make additional spaces.
Did a bit more research and it looks like there is no solution as there is no spaceless tag in blade. I found a solution from someone who wrapping his string in extra hml tags (so that is easy as he ads spaces before and after the tag and the string inside tag si spaceless) but in my case I just need a string no spaces before and after ... I will go the old fashion php way ...
Try this:
#if(...) {{ 'abc' }} #else
I've run into similar problems with spaces.
A workaround I use is this:
Put your if statement into php tags
#php
$myVar = 'abc';
if(...) $myVar = 'cde';
#endphp
and then echo the defined variable
{{$myVar}}
It's a workaround, but I still think we always should remember that it's a PHP environment...
So, simply:
#php
if(...) echo "abc";
else echo "cde";
#endphp
I have found the solution in case there is space issue between #if()#endif and #if.
I have replaced the #if() #endif with the {{$wardname}} variable to be printed using {{$wardname}}#if and its removed conflict with #endif & #if
and applied logic like:
if($city->wardname!="") {
$wardname = "(".$city->wardname.")";
}else{
$wardname = "";
}
Implemented it as:
{{$wardname}}#if
The correct syntax is:
#if(...)
abc
#else
cde
#endif
I never saw unwanted spaces with this one.
I have asked a similar question before but this one is slightly different
I have content with this sort of links in:
Professor Steve Jackson
[UPDATE]
And this is how i read it:
content = doc.xpath("/wcm:root/wcm:element[#name='Body']").inner_text
The links has two pairs of double quotes after the href=.
I am trying to strip out the tag and retrieve only the text like so:
Professor Steve Jackson
To do this I'm using the same method which works for this sort of link which has only a single pair of double quotes:
World
This returns World:
content = Nokogiri::XML.fragment(content_with_link)
content.css('a[href^="ssLINK"]')
.each{|a| a.replace("<>#{a.content}</>")}
=>World
When I try To do the same for the link that has two pairs of double quotes it complains:
content = Nokogiri::XML.fragment(content_with_link)
content.css('a[href^=""ssLINK""]')
.each{|a| a.replace("<>#{a.content}</>")}
Error:
/var/lib/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/css/parser_extras.rb:87:in
`on_error': unexpected 'ssLINK' after '[:prefix_match, "\"\""]' (Nokogiri::CSS::SyntaxError)
Anyone know how I can overcome this issue?
I can suggest you two ways to do it, but it depends on whether : every <a> tag has href's with two "" enclosing them or its just the one with ssLINK
Assume
output = []
input_text = 'Professor Steve Jackson'
1) If a tags has href with "" only with ssLink then just do
Nokogiri::HTML(input_text).css('a[href=""]').each do |nokogiri_obj|
output << nokogiri_obj.text
end
# => output = ["Professor Steve Jackson"]
2) If all the a tags has href with ""then you can try this
nokogiri_a_tag_obj = Nokogiri::HTML(input_text).css('a[href=""]')
nokogiri_a_tag_obj.each do |nokogiri_obj|
output << nokogiri_obj.text if nokogiri_obj.has_attribute?('sslink')
end
# => output = ["Professor Steve Jackson"]
With this second approach if
input_text = 'Professor Steve Jackson Some other TextSecond link'
then also the output will be ["Professor Steve Jackson"]
Your content is not XML, so any attempt to solve the problem using XML tools such as XSLT and XPath is doomed to failure. Use a regex approach, e.g. awk or Perl. However, it's not immediately obvious to me how to match
<a href="" sometext"">
without also matching
<a href="" sometext="">
so we need to know a bit more about this syntax that you are trying to parse.
Is it possible to return a map of hidden links using watir? I have been trying to find some useful documentation, but have been most unsuccessful.
I need it to be generic enough to return any link thats hidden on page regardless of class, id, etc
style=display: none;
This currently returns me all visible links
full_list = #driver.links.map{|a| a.href}
i'd like to do something like (my syntax is probably way off):
hidden_list = #driver.hiddens.map{:style, a => 'display: none;'}
Please, please let me know if there is a way!
Thanks!
You could find all the links that are not visible? and collect their href attributes:
For example, given the following html:
asdf
<a style="display:none;" href="somewhere/invisible">asdf</a>
<a style="display:none;" href="somewhere/invisible2">asdf</a>
You can do:
hidden_list = #driver.links.find_all{ |a| !a.visible? }.collect(&:href)
#=> ["somewhere/invisible", "somewhere/invisible2"]
In PHP I can do this:
<div class="foo <?php if($a) echo "bar"; ?>">
<?php if ($b) echo "</div>"; ?>
It is incredibly convenient. I can break a string in any place, between any quotes, between any HTML symbols, just wherever I want.
And I need to implement the same in Ruby-HTML. I'm trying to port a PHP project to Ruby. I use the Slim template language. I tried this but it doesn't work, Slim throws errors:
<div class="foo
- if (x == 1)
= bar
"></div>
For now with Slim I know only one way:
- if (a == true)
<div class="foo"></div>
- else
<div class="foo bar"></div>
Firstly, duplication. Secondly, my HTML-PHP part of code is quite complicated. It is with two loops (for loop and foreach loop inside it) and I use more than one such an embeds to add div's attributes according to conditions. And just cannot imagine how to implement it with Slim. It throws an error even for this, I cannot break long html string:
- if(i != 5)
<div class="foo bar"
id="item_#{i}"
style="background-color:red;"
data-im="baz">
</div>
- else
Does Slim allow to break strings with conditional ifs between quotes or element attributes? How to do it?
If you're using Rails, you're free to facilitate ActionView::Helpers this way:
= content_tag :li, class: ( a == true ? "foo bar" : "foo") do
inside div
Elsewise you're free to create some helper method to cover this logic for you
Nevertheless it's considered ill practice to include much logic in a view. Consider using some Presenter pattern
edit.
Looking into some slim docs found you're able to achieve your goal this way
div.foo class="#{'bar' if a == true}"
| Text inside div
all im trying to do is to use the simple continue tag but it keeps giving me error like this:
string(145) "Smarty error: [in module_db_tpl:onlyimage4;image_detail line 26]: syntax error: unrecognized tag 'continue' (Smarty_Compiler.class.php, line 590)"
my code is as follow:
{foreach from=$itemlist item="item"}
< .. SOME CODE ..>
{if $maxCol == $colm}
</div>
{assign var ='colm' value = 0}
{$row++}
{continue} **<- THIS IS THE PROBLEM**
{/if}
<.. SOME CODE ..>
{/foreach}
does anyone have any idea whats wrong, I've been googling and see no comments of such sort everyone seem to suggest that this should work.. any ideas guys...
Old question, but you need to use: {$continue} (including the $)
For smarty 2:
I don't think the tag exists. if you read this thread you can see that there are people that want it, and a suggestion to fix it like so. (have not tried)
compiler.continue.php
<?php
function smarty_compiler_continue($contents, &$smarty)
{
return 'continue;';
}
?>
(Bold part my addition)
Create these two files (in this case just one) and put them into your plugins directory
(notice the naming convention compiler.xxx.php).
The good news is, for smarty 3 there is such a tag! see the manual, with example:
{$data = [1,2,3,4,5]}
{foreach $data as $value}
{if $value == 3}
{* skip this iteration *}
{continue}
{/if}
{$value}
{/foreach}
{*
prints: 1 2 4 5
*}