In Codeigniter, Twig project always to refresh cache - twig

In Codeigniter 3.0.6, Twig 1.24.0 project if in twig code I would like to clear all cache on any page reload.
In some cases it seems to me, that after I modify some twig and reload page by CTRL+R, the new changes were not applied to this page.
After I mannually delete twig files it works ok.
twig is included to project as library
https://github.com/kenjis/codeigniter-ss-twig:
$twig_config = array();
$this->load->library('twig', $twig_config);
$twig_Environment = $this->twig->getTwig();
$this->config is filled with :
$this->config::Array
(
[paths] => Array
(
[0] => /mnt/diskD_Work/wwwroot/tb/application/views/
)
[cache] => /mnt/diskD_Work/wwwroot/tb/application/cache/twig
)
In $twig_Environment object output:
$twig_Environment::Twig_Environment Object
(
[charset:protected] => UTF-8
[loader:protected] => Twig_Loader_Filesystem Object
(
[paths:protected] => Array
(
[__main__] => Array
(
[0] => /mnt/diskD_Work/wwwroot/tb/application/views
)
)
[cache:protected] => Array
(
)
[errorCache:protected] => Array
(
)
)
[debug:protected] =>
[autoReload:protected] =>
[cache:protected] => Twig_Cache_Filesystem Object
(
[directory:Twig_Cache_Filesystem:private] => /mnt/diskD_Work/wwwroot/tb/application/cache/twig/
[options:Twig_Cache_Filesystem:private] => 0
)
In codeigniter-ss-twig object I see :
$debug= true; // for development envierement of CI project.
$twig = new \Twig_Environment($this->loader, [
'cache' => $this->config['cache'],
'debug' => $debug,
'strict_variables' => $debug,
'autoescape' => TRUE,
]);
If there are some more options/tuning to update cache any time I reload my page?
Thanks !

You can enable auto_reload, based on your code this should active this option:
$debug= true; // for development envierement of CI project.
$twig = new \Twig_Environment($this->loader, [
'cache' => $this->config['cache'],
'debug' => $debug,
'strict_variables' => $debug,
'autoescape' => TRUE,
'auto_reload' => TRUE,
]);
It is strange that auto_reload is not activated though, because by default auto_reload depends on the option debug if you don't set it manually
When developing with Twig, it's useful to recompile the template
whenever the source code changes. If you don't provide a value for the
auto_reload option, it will be determined automatically based on the
debug value.

Related

WordPress default gallery pagination when call is in page, not post?

It seems I have found the way to make WordPress default gallery pagination to work and to have control over URL forming: https://wordpress.stackexchange.com/questions/401034/pagination-with-wordpress-default-gallery But when gallery call is in post.
When gallery call is in page, it works only if URL is like this: domain.com/pagename/page/2/, domain.com/pagename/page/3/ etc. Trying to have a different URL ends up in stopping it to work.
The part of code handling pagination in functions.php:
// Pagination Setup
$current = (get_query_var('paged')) ? get_query_var( 'paged' ) : 1;
$per_page = 3;
$offset = ($current-1) * $per_page;
$big = 999999999;
$total = sizeof($attachments);
$total_pages = round($total/$per_page);
if( $total_pages < ( $total/$per_page ) ){
$total_pages = $total_pages+1;
}
// Pagination output
$output .= paginate_links( array(
'base' => str_replace($big,'%#%',esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => $current,
'total' => $total_pages,
'prev_text' => __('«'),
'next_text' => __('»')
) );
As long as I keep URL like this domain.com/pagename/page/2/ , other ways for 'base' also work:
'base' => get_permalink( $post->post_parent ) . '%_%',
'format' => 'page/%#%/',
And like this:
'base' => get_pagenum_link( 1 ) . '%_%',
'format' => 'page/%#%/',
But when I try some other URL scheme:
'base' => get_permalink( $post->post_parent ) . '%_%',
'format' => 'paging-%#%',
pagination stops working.
The filter with rewrite tag and rule:
add_filter('init', 'post_gallery_add_rewrite_tag_rule_2022');
function post_gallery_add_rewrite_tag_rule_2022() {
add_rewrite_tag('%current%','(.+)');
add_rewrite_rule('(.+)/paging-/?([0-9]{1,})/?$', 'index.php?name=$matches[1]&paged=$matches[2]', 'top');
}
It seems like add_rewrite_rule is not functioning when gallery call is in page? Or what? Any ideas?

How to apply extension hook in expressionengine

I'm working on expressionengine v2 and i have followed the docs at their site to make extension hooks, i've created a file in third party folder and install that from cp(control panel). Now i don't know how to call that function using hook just to show some text.
$hooks = array(
'after_channel_entry_insert' => 'after_channel_entry_insert',
'before_channel_entry_update' => 'before_channel_entry_update'
);
foreach ($hooks as $hook_name => $method_name) {
$data[] = array(
'class' => __CLASS__,
'method' => $method_name,
'hook' => $hook_name,
'settings' => serialize($this->settings),
'priority' => 10,
'version' => $this->version,
'enabled' => 'y'
);
}
//insert data in extension table
ee()->db->insert_batch('extensions', $data);
//now i want to call this function on hook
function after_channel_entry_insert($data = '') {
die('after_channel_entry_insert');
}

Magento - custom product option don't show in order

I'm try to add custom option to product programmatically whyle add him to cart. I'm use:
$a_options = array(
'options' => array(
'label' => 'Glove Size',
'value' => $attr_value ,
)
);
$item->addOption(new Varien_Object(
array(
'product' => $item->getProduct(),
'code' => 'additional_options',
'value' => serialize($a_options)
)
));
$quote->addItem($item);
This is shows option for product in cart and during checkout process, but don't show option in order information.
I also tried:
$item->getProduct()->addCustomOption('additional_options', $attr_value );
Try to show them via attributes - didn't help.
$params = array('product' => '1919','qty' => 1,
'options' => array(
'glove_size' => $gloves_id,
),);
$cart->addProduct('1919', $params);
Magento version is 1.5
I haven't check that in 1.5 version but the below code will work in 1.7.2 version:
For viewing the custom options you need set options in order items.That can be done through by calling an event sales_convert_quote_item_to_order_item
<sales_convert_quote_item_to_order_item>
<observers>
<jrb_setcustomoption_observer>
<type>singleton</type>
<class>jrb_setcustomoption/observer</class>
<method>salesConvertQuoteItemToOrderItem</method>
</jrb_setcustomoption_observer>
</observers>
</sales_convert_quote_item_to_order_item>
Set the details options in your observer
public function salesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)
{
$quoteItem = $observer->getItem();
if ($additionalOptions = $quoteItem->getOptionByCode('additional_options')) {
$orderItem = $observer->getOrderItem();
$options = $orderItem->getProductOptions();
$options['additional_options'] = unserialize($additionalOptions->getValue());
$orderItem->setProductOptions($options);
}
}
For More details you can find in this article:
Magento - custom product option don't show in order
Thanks to Vinai

joomla custom search plugin not showing results but return object

I'm making a custom component for joomla 3.1 and I've followed this tutorial => http://docs.joomla.org/Creating_a_search_plugin (I had to make many changes but in the end it worked).
..The object returned by my custom plugin looks like core content plugin of joomla, but the problem is that the results are not displayed in search results screen... what I'm doing wrong?
this is the object that the plugin return:
Array
(
[0] => stdClass Object
(
[title] => Test
[metadesc] =>
[metakey] =>
[created] => 2013-06-05 16:10:14
[text] => some text here
[section] => Test
[slug] => 8:test
[catslug] => 11:test
[browsernav] => 2
[href] => index.php?option=com_content&view=article&id=8:test&catid=11:test&Itemid=xxx
)
)
Await for some anwsers!
Regards!

Empty Grid in jqgrid

I am trying to integrate a grid to my PHP project, JQgrid looked so easy!!
When i Integrated I was only able to see the grid, not the data in the grid!
I have just change the db settings of the sample code to work with my DB.
Debug results:
When I debugged with firebug I am able to see the db rows in the consolde mode of firebug.
Here with also pasting the logs of jqGrid.log
It also throws a warning msg "Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\Users\Karthik\Desktop\apache\htdocs\php\jqGrid.php(1) : eval()'d code on line 1"
Both files resides in root directory. Some clues to troubleshoot
PHP Code"myfristgrid.php"
require_once 'jq-config.php';
// include the jqGrid Class
require_once "php/jqGrid.php";
require_once "php/jqGridPdo.php";
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$conn->query("SET NAMES utf8");
$grid = new jqGridRender($conn);
$grid->debug = true;
$grid->SelectCommand = 'SELECT * FROM question';
$grid->datatype = 'json';
$grid->setColModel();
$grid->setUrl('myfirstgrid.php');
$grid->setGridOptions(array(
"caption"=>"This is custom Caption",
"rowNum"=>10,
"sortname"=>"id",
"hoverrows"=>true,
"rowList"=>array(10,20,50),
));
$grid->setColProperty("id", array("label"=>"ID", "width"=>60));
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
jqGrid.log
Executed 2 query(s) - 2011-01-26 22:50:28
Array
(
[0] => Array
(
[time] => 2011-01-26 22:50:28
[query] => SELECT COUNT(*) AS COUNT FROM question
[data] =>
[types] =>
[fields] =>
[primary] =>
[input] =>
)
[1] => Array
(
[time] => 2011-01-26 22:50:28
[query] => SELECT * FROM question ORDER BY id asc LIMIT 0, 10
[data] =>
[types] =>
[fields] =>
[primary] =>
[input] =>
)
)
You can't properly use setColProperty in the jqGrid.

Resources