codeigniter

  • Insert form inputs with the same input name into database rows using codeigniter
  • How can I just get the "Year" portion from the output of timespan( ) in CodeIgniter?
  • Codeigniter - chaining several query results
  • CodeIgniter controllers, how to avoid repeating code?
  • Query differences
  • Codeigniter , hook not loading Input class correctly
  • how to define Global variable in codeigniter?
  • Codeigniter: Passing helper functions to the CI error_404.php file
  • how to check array in where condition in codeigniter?
  • How to execute a function at a certain date in a web application?
  • joomla

  • Database connection error (2): Could not connect to MySQL for Yoomla on local machine
  • What is the PHP methodology used in Joomla (OOP or procedural)?
  • Adding sorting and pagination to data from different DB using php or mysql
  • migrating from 1.5 to joomla 2.5
  • display an extrafield over product image with virtuemart when typed by user (something like tshirt designer)
  • Joomla module position showing
  • Joomla update query not working
  • Joomla - Joomfish Error Blank index.php
  • call controller from a view
  • Installation problem: couldn't find XML in the pack
  • laravel

  • Signed route for email verification does not pass signature validation
  • Eloquent how to do something when delete or update operate on a special model
  • FullCalendar - Removing the dot in event
  • Library Class not found in Laravel 4
  • Laravel 4 Form Post
  • Laravel javascript require perfect-scrollbar
  • laravel Model Undefined index after add static function boot()
  • SQLSTATE[HY000]: General error: 1364 Field 'care' doesn't have a default value
  • Intervention: Resize image twice?
  • Understanding Routing in Laravel
  • Ezoic report this ad Accepted answer

    This answer is related to 0.12.0 version (probably applies as well to 0.13.0 as well)... You might be using some older version as you are using the deprecated loadTemplate function.

    To answer you latest question, I don't think that you can use the templates with the addObject (ok, not 100% sure about it, but quote certain). But a working approach would be to use single template file where you have one page template of your stickers defined (including your pagebreak) and wrapped around with template block tags, i.e:

    ${CLONEBLOCK}
    Here is your sticker page definition (6 stickers + pagebreak)...
    ${/CLONEBLOCK}
    

    And then in your code you would just clone this block as many times as needed:

    // the class path is probably something different with your codeigniter
    $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('application/controllers/Sticker.docx');    
    $templateProcessor->cloneBlock('CLONEBLOCK', count($persons)/6);
    

    And you would assign your template values quite similarly:

       // note! add the limit 1 as the third parameter (otherwise it will
       // write the this value on all of the pages)
       $templateProcessor->setValue('Mname'.$counter,  $row->mname, 1);
                                            

    I know this is an old question but I was looking for a similar answer and found the missing link to make this answer work, so I wanted to share it with you.

    The answer by ejuhjav is in principle correct, but with the current version as of today (v0.16.0) this will work.

    In your word template, you have the following code block:

    ${CLONEME}
    1.  ${Title}
    ${/CLONEME}
    

    (the "title" being formatted as a numbered heading)

    Now you want to dynamically insert x headings for example, right? So what you do is simple. You clone the block x times and then you set the value for each iteration. The error which was made in other answers is that the setValue method works as a simple search and replace. So basically you always look to replace the first ${Title} placeholder it finds and move onto the next one - but you have to make sure that the search and replace is limited to the first finding like this:

    $templateProcessor->setValue('Title',  "Testtitel 1", 1);
    

    Which will then basically iterate through each cloned heading.

    This works perfectly, of course this is not done dynamically for dummy reasons:

    // Template processor instance creation
    $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('Sample_23_TemplateBlock.docx');
    $templateProcessor->cloneBlock('CLONEME', 3);
    $templateProcessor->setValue('Title',  "Testtitel 1", 1);
    $templateProcessor->setValue('Title',  "Testtitel 2", 1);
    $templateProcessor->setValue('Title',  "Testtitel 3", 1);
    $templateProcessor->saveAs('ClonedHeadings.docx');
    

    I hope it helps someone in future.

    Andreas

  • reuse template in the same document [PHPword]
  • Is there a way to get the document root on localhost in the same format that we get on remote servers (like /home/MyUserName/public_html)?
  • Template 1.4.1 - How to render the same layout without retyping all write command
  • why the same $data array is passed to all views at the same time in codeigniter if i use template library created by phil?
  • CodeIgniter call function within the same class
  • How to fetch title of an item from a database and send it to the header template in CodeIgniter
  • CodeIgniter query: How to move a column value to another column in the same row and save the current time in the original column?
  • PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP
  • How to join the same table twice and assign table aliases in Codeigniter?
  • Cannot call the same static method from identical method from the same class
  • How can I instantiate multiple instances of the same object in Codeigniter?
  • How can I keep the same url in the address bar for every page?
  • how to give multiple colors in the same cell in a full calendar?
  • Severity: 8192 Message: Methods with the same name as their class will not be constructors in a future version of PHP;
  • The blade template engine can be used with codeigniter?
  • Possible for PHP app built on top of codeigniter to connect to a MySQL AND a mongoDB database at the same time?
  • alias value in where clause for the same query
  • My models all tend to look the same
  • Communication between two PHP applications on the same server?
  • CodeIgniter/Datamapper: Two one-to-many relationships to the same table not working
  • How do I use parameters of parent class method with the same method name?
  • How do I use the same object for multiple hooks in CodeIgniter?
  • Should I name my actual controller files the same as my view files in Codeigniter?
  • CodeIgniter: loading multiple models in the same controller
  • Codeigniter Shopping Cart: Adding the Same Product Again
  • character encoding of the HTML document was not declared codeigniter
  • How remember_token is generated by laravel automatically? Can we do the same in codeigniter?
  • Codeigniter: Can I return multiple values from the same function?
  • Mulitple LIKE db query using associative array- but all from the same column name...?
  • Codeigniter - Add a product with the same ID if options are different
  • More answer with same ag

  • Google Adwords and CodeIgniter GET Variable Callback URL
  •