custom table of content in mdpf - php

I use mdpf plugin. And I create table of content follow this.
I create html view in pdf_frm01.php file
<html>
<body>
<!-- focus this and I want in same page -->
<div class="toc">
<div>Table of content</div>
<tocpagebreak />
</div>
<!-- -------- --->
<div style="page-break-before : always">
<tocentry content="1. bbbbbbbbb" />
<div>page 2</div>
</div>
<div style="page-break-before : always">
<tocentry content="2. cccccccccc" />
<div>page 2</div>
</div>
</body>
</html
And I create pdf.php for control mpdf action
$pdf_custom = getcwd().'/lib/mpdf/mpdf.php';
require_once($pdf_custom);
$pdf = new mPDF();
$html = $this->load->view('pdf_frm01.php',$data,true); //load text from file
$pdf->writeHTML($html);
$pdf->Output("frm_01",'I');
But. I have a problem.
I want to create a custom table of content style.
I want Table of content (text) on top the table of content.
In table of content. I want to change font-family, font-size, line-height etc.
How to create a custom content table style? or can you recommend me?

Read documentation: https://mpdf.github.io/what-else-can-i-do/table-of-contents.html
you can add custom CSS:
$mpdf->WriteHTML('style.css'), 1);
to change default style TOC. But the problem is that some of custom style not working - I cannot remove "bold" from TOC font.

Related

Add class to a div in header from template file in Wordpress with filter

I have a div in header.php like this:
<div id="myDiv">Some text</div>
I want to add a class to that div from a template/template-part file based on data/logic i have in the template file. I tried creating filter like this:
add_filter( 'toggler_class', 'my_class_add',10, 1 );
function my_class_add($class='') {
echo 'class="'.$class.'"';
}
And in header.php i had:
<div id="myDiv" <?php apply_filters('toggler_class', ''); ?> >Some text</div>
Which prints:
<div id="myDiv" class="">Some text</div>
This works; but now I want to modify that filter in a template file so that the div gets a new class:
<div id="myDiv" class="myNewClass">Some text</div>
How can I achieve this?

Adding hyper link to the footer text of a wordpress website (darina theme by besquares)

I am unable to insert hyper links in my footer texts.
I have a wordpress theme (darina by bessquare) which has a space for editing the footer text in the customizer section, however the section does not accept codes only text. I want the text I input to have hyperlink. I have tried changing the editing the footer.php file but it doesn't work as the text in the customiser overrides the footer.php file. The theme has a section for 'custom css' and 'additional code' please help me with a code I can use to override that text and have hyper links in it.
</div>
<?php } ?>
<div class="left-block col-md-8">
<p class="copyright-text">
<?php echo esc_html(get_theme_mod('zn_footer_copyright', 'Copyright darina. 2016 - All rights reserved.' )); ?>
</p>
</div>
</div>
</div>
</div>
</footer>
<!-- #colophon -->
<script type="text/javascript">
var PageUrl = '<?php echo esc_js(darina_current_page_url()); ?>';
</script>
</div><!-- #page -->
I need footer text with hyperlinks.
Before touching the theme's template, try typing youlaif.com into the copyright text area of your customize menu.
If that doesn't work, just add the anchor into the PHP statement.
<?php echo esc_html(get_theme_mod('zn_footer_copyright', 'Copyright youlaif.com. 2016 - All rights reserved.' )); ?>

Simple html dom and php fetch hidden content

I am using Simple HTML DOM parser to fetch some data. Everything works great but I am facing a problem when I have enabled the read more plugin on my WordPress site.
The hidden content (the rest content of the article) is inside this div.
A sample:
<div class="mycontent">
Here is some content
<div class="brm" style="display: none;">
Here is another content but it's not vissible because the style of this div is set to display:none
</div>
<p>read more..</p>
</div>
So far I am using:
$url = "www.myurl.com";
$html = new simple_html_dom();
$html->load_file($url);
$maindiv = $html->find('div.mycontent',0)->outertext;
it displays everything except the content inside the div <div class="brm" style="display: none;">
Any ideas how to get the hidden content?
It actually does get that div:
include 'simple_html_dom.php';
$str = <<<EOF
<script type="text/javascript">
<div class="mycontent">
Here is some content
<div class="brm" style="display: none;">
Here is another content but it's not vissible because the style of this div is set to display:none
</div>
<p>read more..</p>
</div>
EOF;
$html = str_get_html($str);
echo $html->find('div.mycontent',0)->outertext;
// <div class="mycontent"> Here is some content <div class="brm" style="display: none;"> Here is another content but it's not vissible because the style of this div is set to display:none </div> <p>read more..</p> </div>

mPDF - Content from specific div that is visible + add a save button

So I'm trying to set mPDF on my site, but the thing is, on the page that I want to create pdfs on, I get all of the content inside divs based on the posts count. So it looks something like this:
<div id="all-posts">
<div id="some-post">
content
</div>
<div id="some-other-post">
content
</div>
<div id="post-with-long-title">
content
</div>
</div>
And then I have a select, with options values which are equal to the div IDs inside all-posts. And when you pick an option from the select, that div is showed. Now what I need to do is show a Save PDF button, and when that is clicked, get the content from the div that is currently showing (based on whats selected in select tag) and save the .pdf. Is something like this even possible?
Update:
<?php include("mpdf/mpdf.php");
$mpdf=new mPDF();
ob_start(); ?>
<div id="all-posts">
<div id="some-post">
content
</div>
<div id="some-other-post">
content
</div>
<div id="post-with-long-title">
content
</div>
</div>
// Now collect the output buffer into a variable
<?php $html = ob_get_contents();
ob_end_clean();
$mpdf->WriteHTML($html);
$mpdf->Output();
exit; ?>

Hiding a div with the same class as another using jQuery?

Basically, I would like to accomplish the following with jQuery:
<div class="120 most-voted">
<!-- DON'T HIDE THIS DIV -->
</div>
<div class="110 voted">
<!-- some stuff here -->
</div>
<div class="120 voted">
<!-- hide this div with class '120' since there's already
another div with class '120' at the top -->
</div>
<div class="23 voted">
<!-- some stuff here -->
</div>
EDIT: The numbers are dynamically generated by a PHP function:
<?php $postid = get_the_ID(); // capture the id ?>
<div id="<?php echo $postid; ?>" class="most-voted">
I don't want to hide the div at the top.
Any suggestions (I don't mind wrapping another div in the div at the top to accomplish this result)?
This will make the first div with class "v120" visible and all others hidden:
var theClass = "v120";
$("div." + theClass).first().show().end().not(":first").hide();
Live example
(I added the "v" to "120" because I wasn't sure whether "120" is a valid CSS class.)
How that works:
Find all divs with the class - $().
Reduce that set temporarily to the first match - .first()
show that one (in case it used to be hidden)
End the temporary reduction of the set - .end()
Reduce the set to only the matches that aren't the first - .not(":first")
hide them
Its not valid html, the id must be unique within the document
http://www.w3.org/TR/html401/struct/global.html#h-7.5.2
Use rel attributes instead of IDs. Then use selector like:
$('div.voted[rel=110]')
If you want to use same div, you should conceder using a class attribute since double id is not allowed.
<div class="most-voted id_120">
<!-- some stuff here -->
</div>
<div class="voted id_110">
<!-- some stuff here -->
</div>
<div class="voted id_120">
<!-- hide this div with id 120 since its already
at the top in the div with class most-voted -->
</div>
<div class="voted id_100">
<!-- some stuff here -->
</div>
use this to locate the first on http://api.jquery.com/first-selector/

Categories