Closed rhodges closed 5 years ago
When content differs (pdf vs web) within a single text area. For example:
Ecoregions - PDF version has map included between what falls within a single text area in web version
Web | |
---|---|
![]() |
![]() |
example:
Oregon Conservation Strategy 2016: Ecoregions-86
~strategy species are not referenced in ecoregion posts, so there is no way to know which species need to be included in each ecoregion~
~- Referenced in strategy species posts~
~Possible solutions:~
SOLVED
[post_strategy_species]
Step 1:
postStrategySpecies
Step 2:
kalins_pdf_page_shortcode_replace
create a new variable for the shortcode$str = preg_replace_callback('#\[ *post_strategy_species *(id=[\'|\"]([^\'\"]*)[\'|\"])? *\]#', array(&$postCallback, 'postStrategySpecies'), $str);
Step 3:
[post_strategy_species]
~ ### Conservation opportunity areas on Ecoregion posts~
~COAs are not referenced in ecoregion posts, so there is no way to know which COAs need to be included in each ecoregion~
~- Referenced in strategy species posts~
~Possible solutions:~
SOLVED
~### Limiting factors and recommended approaches~
~1. Where is content coming from?~
~2. If content coming from post type, would need to know the maximum number a post could have. We have no way to loop through a list and need to be explicit for each factor and approach. The maximum number will work because there is no error thrown for missing factors and approaches~
~Solution~
SOLVED
[post_limiting_factors]
Step 1:
function postMetaLimitingFactors($matches) {
$the_field = get_post_meta( get_the_ID(), 'factors_repeat_group', true );
$s = '';
foreach($the_field as $entries => $entry ) {
$s = $s . apply_filters('the_content', $entry['ecoregion_meta_factor_title']) . apply_filters('the_content', $entry['ecoregion_meta_factor_description']) . apply_filters('the_content', $entry['ecoregion_meta_approach']);
}
return $s;
}
Step 2:
kalins_pdf_page_shortcode_replace
create a new variable for the shortcode
example:
$str = preg_replace_callback('#\[ *post_limiting_factors *(name=[\'|\"]([^\'\"]*)[\'|\"])? *\]#', array(&$postCallback, 'postMetaLimitingFactors'), $str);
Step 3:
[post_limiting_factors name="factors_repeat_group"]
~### Any brackets are outputted as a string~
~For any meta box that uses brackets ("[ ]"), which is handy for pulling wordpress content into a post, anything between the brackets will get outputted as a string~
PARTIALLY SOLVED
Added a preg_replace
function that matches for [caption]
brackets and replaces those with an empty string if found. Full function:
if (preg_match('/\[caption[^\]]*\]/', $str, $output)) {
//remove all captions surrounding images and whatnot since tcpdf can't interpret them (but leave the images in place)
$str = preg_replace('/\[caption[^\]]*\]/', '', $str);//replace all instances of the opening caption tag
$str = preg_replace('/\[\/caption\]/', '', $str);//replace all instances of the closing caption tag
}
Will need a new similar function for each shortcode we find. This is because shortcodes are named by the developer.
Ready for review: ecoregions.pdf
Todo:
Have an example of PDF export for ODFW to use as shared language to tell us what they ACTUALLY want (in detail).