Yii - how to include phpdocx files? - yii

I'm trying to include phpdocx files in my Yii project. On a standalone php script, all I have to do is
require_once 'phpdocx/classes/CreateDocx.inc';
Not sure how to do it with Yii. I put the folder under protected/components/thirdparty/phpdocx. And added the line above (with correct path) in config/main.php, but Yii can't find the rest of the .inc files.
How do I include those?

Try this:
define('PHPDOCX_INCLUDE_PATH', (dirname(Yii::app()->basePath)).'/components/thirdparty/phpdocx');
spl_autoload_unregister(array('YiiBase','autoload'));
require_once PHPDOCX_INCLUDE_PATH.'/classes/AutoLoader.inc';
spl_autoload_register(array('AutoLoader','load'));
spl_autoload_register(array('YiiBase', 'autoload'));
// your code
$docx = new CreateDocx();
$docx->addTemplate('files/mytemplate.docx');

You need to use the namespacing version of Phpdocx, and then just load the library in composer.json.

Related

Can I add a custom section to a .vue file

I am using single file Vue components in my app. What I'd like to do is add a new section, . Then, at build time, compile all of these configs into a single config file.
Is there a simple way to do this?
Thanks,
It turns out this is possible using Custom Blocks.

How to generate txt & xml files in nuxt SSR?

Is there any way of generating a Google : ads.txt file every time i build my SSR project?
There is a module called: sitemap-module from nuxt-community, it is used to generate a sitemap xml file, and that file can be accessed by http://domain.tls/sitemap.xml. and i want something like that.
So currently i'am achieving this by building the project, then manually put ads.txt it in : /var/www/site/.nuxt/dist/client/,
The problem with this is that everytime i rebuild the project i loose /var/www/site/.nuxt/dist/client/ folder then i have to add ads.txt file again.
I would like to know how i can hook up my code to tell nuxt to generate ads.txt file and put it in /var/www/site/.nuxt/dist/client/
Not sure if it makes sense, but i hope someone will understand.
Place your ads.txt file in a directory named static as mentioned here. All the contents of the static directory can be accessed via example.com/{filename.extension}
If you are not using nuxt.js and just using vue js, place it in a public directory right next to src directory.
Haven't found any way of solving this in nuxt, so i decided to redirect all https://domain.tld/ads.txt in Nginx configuration.
/etc/nginx/sites-available/default.conf
#redirect all txt request
location ~* ^.+.(txt)$ {
root /var/www/other.files/;
}
So i think i'll stick to it.

A Module For Installing Modules in Yii

I am wondering if there is a module that gives the ability to install modules via an interface instead of copy a module files and create database tables manually and add it to config/main.php .
Is there any ? I mean something like what is in Joomla or Drupal?
As of now, I don't think there is something like this on Yii.
What we did for our projects, is this.
We created our module, that will automatically create / copy the files and the same time, add the configuration files.

Use normal PHP libraries in CodeIgniter

I'm new to CodeIgniter and I'm trying to use the Tumblr php library; however I'm not sure how can I adapt it to work with CodeIgniter (if such thing is possible).
I managed to find a few Tumblr CI libraries but they don't provide all the methods available (like tag searching), and the most advanced by BIOSTALL only supports the v1 of the Tumblr API.
Any advices?
You need to do these steps:
Download Tumblr API library for CodeIgniter here
tumblr.php (in config folder) put on your config folder
Change the config file with your parameters:
$config['tumblr_consumer_key'] = '';
$config['tumblr_secret_key'] = '';
$config['tumblr_url'] = 'good.tumblr.com';
$config['callback_url'] = 'controller/method';
$config['auth_callback'] = 'controller/method';
Tumblr.php (in library folder) put on your library folder
OAuth.php (in third_party folder) put on your third_party (create if didn't exist).
Use it. For example:
$this->load->library('Tumblr');
$blog_info = $this->tumblr->blog_info();
// Blog info returned in object
echo $blog_info->title; // echo blog title

ActiveAdmin: changing css file?

I'm confused on where to put my new css file for ActiveAdmin to use. I have a folder called public/admin/active_admin.css and here https://github.com/gregbell/active_admin/issues/261, it says to put it in active_admin.rb but this doesn't exist in my application. Where does it go?
All you need to add is
# active_admin.rb
config.register_stylesheet 'active_admin_custom.css'
in the file config/application.rb (or an environment-specific config file) then the file /public/stylesheets/active_admin_custom.css
or you can create a new file:
config/initializers/active_admin.rb and put that line of code in there.