JSON-LD in der Suchmaschinenoptimierung

Jeder Website-Betreiber hat ein großes Ziel: Mehr Besucher auf seine Website zu bekommen. Viele überlassen es dabei den Suchmaschinen, den Sinn der Website zu verstehen.

Mit JSON-LD helfen wir den Suchmaschinen, die Inhalte einer Website zu verstehen, zu indexieren und zu aggregieren. JSON-LD in der Suchmaschinenoptimierung weiterlesen

PHP-Function: Create slugs from string

Every website needs to implement readable URLs for internal linking. When you are using a blogging tool like WordPress or a CMS like Typo3, you automatically get the URL slug generator built in.

But sometimes, you are developing your own software and are in need of a function that simply generates a slug for you.

Search no more, because here it is: the PHP function to generate slugs for you.

This PHP function takes a simple string as first parameter, which will be turned into your slug. In this example, we are using the string  This is just a small test for a slug creation .

The function slugify  then returns a nice, readable slug for you.

If you want to use another delimiter, simply pass it as the second parameter to the function.

 

jsPDF / html2pdf: add header and footer text to each page

In a recent project I needed to add header and footer text (like page count) to every single generated html2pdf / jsPDF page.

There are a lot of instructions on the web, but none of those are really doing what I wanted.

Basically, I needed to use the callback  function of  html2pdf to loop over the total pages, and then access that single page to add text to it.

html2PDF: Add a header and footer to every page

So the first step is to use the callback  function of html2pdf :

And within the callback function, I am looping over the pages of the generated document. You can find the total number of pages within the returned jsPDF-Object  which is called  pdfObject in my example.

Using this code you can simply add a header and a footer text to each page of the generated PDF document.

To add a header text, you can simply add the following line to the above code.

This will add the text „my header text“ at the position x = 10, y = 10 to every page of your PDF document.