How to remove spaces from pagination on CodeIgniter? - codeigniter

I use the pagination helper from CodeIgniter and it works. But when I see the result in my browser, I can observ unwanted spaces. CodeIgniter seems to insert them in an automatic way.
In my view:
<div><?php echo $this->pagination->create_links(); ?></div>
The code generated behind (html):
<div>
Previous
1
2
<strong>3</strong>
4
5
Next
Last
</div>
So there is a space before my previous link and two spaces before my "Last" link. Same thing happens when it's reversed (two spaces after my "First" link).
Why? It really blow my mind! Please do you know how to remove them?
Any suggestions gratefully received.
Solution (thanks to uzsolt's answer) : It works with first_tag_close and last_tag_open set to '' (see comments for more details).

Maybe you can set num_tag_open and num_tag_close config variable.

After trying all sorts of things by setting the config values from both within my controller and a application/config/pagination.php file. I managed to solve it by going into system/libraries/Pagination.php and reset the default values without any ' '.
Hope this helps someone else.

Related

Visualforce Syntax Error for IF statement inside a Apex Repeat

I am receiving a syntax error and having a hard time identifying where I am going wrong.
I have researched several different alternatives such as wrapping <apex outputText> as well as using multiple version of {! leading into my variable calls. Unfortunately, I'm just having a hard time grasping which series of errors I am making to cause this syntax error.
The Crux of the code is:
<td>
{! IF(isTenant, ${woli.Repair_Product__r.Bill_Rate_Retail__c}, ${woli.Repair_Product__r.Bill_Rate__c})}
</td>
For variable References. This is located in a where woli is defined as:
<apex:repeat value="{!woliList}" var="woli">
and isTenant is simply hardcoded in my controller to be false for testing purposes:
public Boolean isTenant = False;
I expected my Apex Repeat command to populate different bill rates depending on the value of isTenant, but of course with the Syntax error I cannot tell if I am on the right track. Helpful tips on when multiple {!} are or are not required in Visual Force references would be helpful. I am also curious when, if ever, I should be using single or double quotation marks to define the output of the if condition.
UPDATE:
I thought perhaps I it was as simple as me not binding the condition statement to a variable in the controller class so I modified to this:
<td>
{! IF({!isTenant}, ${woli.Repair_Product__r.Bill_Rate_Retail__c}, ${woli.Repair_Product__r.Bill_Rate__c})}
</td>
Adding appropriate get/set in the controller. But alas this was not the problem the developer console still gives a mystery Syntax Error.
You don't need $ signs. Dollar is used for special fields that "depends who's looking" and other stuff not really related to data in database. You can have $CurrentPage, $User.Name, $Profile.Name, $Label.someText (that one counts as "depends who's looking" because if your preferred language is French it can display translated version.
And second thing - if you're already inside the {! some merge field syntax } you don't need more curly braces.
Try
{! IF(!isTenant,
woli.Repair_Product__r.Bill_Rate_Retail__c,
woli.Repair_Product__r.Bill_Rate__c
)}

cs cart how to pass variables through tpl files

in the checkout page, I am trying to pass a variable through step 2 to step 3. I want to check the town of the user and do specific payments methods according to the town of the user.
I tried a lot, but couldn't see the variable. It always returns blank!
In the step 2, (this is the page with the address and everything about the user-client) I did this:
{assign var="town" value="$user_state"}
How can I pass this variable to step 3? (file name is payment_methods.tpl)
*I read something about smarty...
I tried {php} code...
Any help? thanks in advance!
ok I found a solution to my problem.
Inside the step_profile_fields.tpl file, I have done my calculations and capture this variable, for example:
{capture name="state_of_user"}{$ship}{/capture}
In step 4, I have included the previous tpl file (step_profile_fields.tpl)
and grab this value through:
$smarty.capture.state_of_user
For example I have this:
{include file=".." user=$smarty.capture.state_of_user}
if someone need more help. please let me know!

Need trick to use cached value in nocache section

I want to iterate thru single array and disable caching only for some elements.
So my idea was to keep key and get element by key in nocache section. Unfortunatelly i haven't found any possibility to:
assign cached $rec#key in nocache section,
or keep variable key definition in cached section.
Is there any way (without smarty code modification) to do it ?
here my test.tpl:
{foreach $array as $rec}
{if $rec.dynamic}
{assign var="key" value=$rec#key}
{nocache}
{$array[$key].text}
{/nocache}
{else}
{$rec.text}
{/if}
{/foreach}
and test.php:
<?php
include_once 'libs/Smarty.class.php';
$smarty=new smarty();
$smarty->caching=1;
$smarty->assign('array',array(
'r1'=>array('dynamic'=>true,'text'=>'dynamic'),
'r2'=>array('dynamic'=>false,'text'=>'static')
));
$smarty->display('test.tpl');
(of course i will use it for much more complicated things than text display:) )
I tried lot of tricks and by myself i think it is not possible, please tell me i am wrong :)
Finally, I have found a solution: Use count in your loop.
{nocache}
{counter start=0 skip=1 assign="count"}
{/nocache}
{section name="co" loop=$publication}
{nocache}
{$publication[$count].id}
{counter}
{/nocache}
{/section}
What you are trying to accomplish is, as of Smarty 3.1.x, not possible. With 3.2 Smarty will allow you to "export" values into a {nocache} section to ensure they're available when the template is re-executed.
Until 3.2 is released (don't ask for a date, I don't know) you may be able to do this yourself using a compiler function.

Smarty assigned template variables

Looking through the Smarty debug console I discovered the variable {$u}, which contains the array video => "".
{$u} also contains photo, interview, etc. which is taken from the t1 table in the database. The database does have a url in the video column, but it is not being captured in {$u}. The problem right now is that I can't figure out where {$u} is populated.
What is the best way to find out where $u is populated?
If you can't debug your code line by line (with Zend or Xdebug), try to search your PHP code for ->assign('u', ->assign("u" or your Smarty templates for {$u=, {assign name="u", etc...
Unfortunatly there is no way to make Smarty tell you automatically where a varible was declared.

Descendent-or-self in InfoPath

I want to use XPath code in an InfoPath form to sum the data in field12 when field11 is equal to IT. I tried using the following code, but it doesn't work.
number(sum(/descendant-or-self::node()/my:group12[my:field11 = "IT;"]/my:field12))
I suspect this has to do with the multilayering of groups, as shown below. Does anyone know the code that would allow me to get to the data in group12? Thanks in advance for your help.
myfields>group9>group10>group11>group12>field11 field12
Genipro
Looks like:
number(sum(/descendant-or-self::my:group12[my:field11 = 'IT;']/my:field12))
could be right.
decendant-or-self should not be necissary in this case (unless you need the expression to work even if group12 is moved).
This should work fine:
sum(/my:myfields/my:group9/my:group10/my:group11/my:group12[contains(my:field11,'IT')]/my:field12)
It doesn't matter if any of the other groups are repeating either. All group12's will be checked.

Resources