Development

Taxonomy pagina’s ontoegankelijk maken

Standaard zijn taxonomy pagina’s altijd te benaderen via taxonomy/term/. Dit is niet altijd wenselijk en kan via de template.php worden ondervangen. De vraag is of dit de meest aangewezen plek is, maar het functioneert!

De oplossing is om de taxonomy_term_page() functie te overriden

function <theme>_taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {}

Door dan de drupal_not_found(); functie aan te roepen, worden deze pagina’s automatisch voorzien van 404 meldingen.

function <theme>_taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
drupal_not_found();
}

Je kan natuurlijk ook per vocabulary een uitzondering maken en daar een view-output op laten zien.


// we need to know the vid, so we ask for more information about the term
$term = taxonomy_get_term($str_tids[0]);
if($term->vid == <your_vid>){
$output = views_embed_view('bedrijven_overzicht','block_1',$term->tid);
return $output;
}
else{
drupal_not_found();
}

Ik hoor graag als er andere, betere, mooiere manieren zijn, maar het heeft voor mij in ieder geval zijn doel bereikt.

Replace first matching string occurence not in link [PHP Quest]

I’m trying to replace a string in PHP which is not a link.

Example:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mattis sodales viverra. Pellentesque feugiat diam quis nisl commodo quis dignissim justo posuere. <a href=”http://d-media.nl/stringtolookfor“>Donec</a> a est turpis, vel eleifend magna. In vitae dictum lorem. Curabitur vel adipiscing purus.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean stringtolookfor mattis sodales viverra. Pellentesque feugiat diam quis nisl commodo quis dignissim justo posuere. Donec a est turpis, vel eleifend magna. In vitae dictum lorem. Curabitur vel adipiscing purus.</p>

I would like to find the first occurence of ‘stringtolookfor’ which is not part of a link (thus within <a href=”">)

Google +1 voor WordPress

Heb jij ‘m al, de nieuwe hippe gave Google +1 button op je WordPress weblog? Niet?

Het is nu supermakkelijk te installeren: http://wordpress.org/extend/plugins/google-1-button-automator/

Kies even waar je ‘m wilt zien, op je overzichten of alleen op de detailpagina’s. In de header of de footer van het bericht en je bent weer helemaal bij!

UPDATE 15 juni 2011: De eerste 1000 downloads zijn een feit!

Single Invoke Cronjob Drupal with SuperCron

If you use SuperCron for Drupal (who doesn’t?!) you can call the different invokes seperately. Very handy if you would like to check if there’s email via mailhandler every 10 minutes, without running the complete cronjob.

How? You will have to find the key named SUPERCRON_SAFETY_VARIABLE and this key can be found in the database table variables.

And then? You put in a cronjob for example like this http://example.com/supercron.php?safety=<your_found_key>&module=<the_module_you_want_to_invoke>

UPDATE: ok. that was too fast! the variable changes on every cron run, so this doesn’t work! I’ll post an update soon!

Get the value for a key [CCK / Views]

I was trying to get a value in a views tpl. The value was a predefined list of text values. Views gave the key value, but of course i needed the string value.

content.module contains the function content_format() which does the job for you. More information about this function: http://api.audean.com/api/function/content_format/API+Reference