• Hi,
    What would the proper way to fork a page.php file with the below code at the top into a template?

    <?php /* * single page * semplice.theme */ ?>
    <?php get_header(); # inlude header ?>

    If I try adding the below basic template code and nothing else any page it is applied to crashes:

    <?php /* Template Name: testtemplate*/ ?>
    <?php /* * single page * semplice.theme */ ?>

    Here is the error but I don’t think it is related:
    Parse error: syntax error, unexpected 'p_get_attachment_image_src' (T_STRING) in /nfs/c01/h08/mnt/34978/domains/idrawdetroit.com/html/wp-content/themes/semplice/page-home.php on line 25

    If I remove this it still crashes with the same error:
    <?php /* * single page * semplice.theme */ ?>

    I suspect this has something to do with the *semplice.theme* designation bit. Can anyone point me to a tutorial or documentation that I can reference for this error? The theme’s designated forum said this was a wordpress issue… ??
    Thanks very much.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Can you add it here the entire code of that template?

    Thread Starter kvnmcwebn

    (@keeven-even)

    Hi, sure it’s big!

    <?php 
    /*
     * single page
     * semplice.theme
     */
    ?>
    <?php get_header(); # inlude header ?>
    
    <?php if ( post_password_required() ) { ?>
     
    	<div class="container">
    		<div class="row">
    			<div class="span12">
    				<?php echo get_the_password_form(); ?>
    			</div>
    		</div>
    	</div>
     
    <?php } else { ?>
    
    	<?php if(get_field('use_semplice') !== 'active' && get_field('use_semplice') !== 'coverslider') : ?>
    	
    		<section id="page-content" class="fade-content">
    			<div id="post" class="container">
    				<?php if (has_post_thumbnail( $post->ID ) ) : ?>
    					<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
    					<div class="row">
    						<div class="span12 featured">
    							<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" alt="Featured Image"  /></a>
    						</div>
    					</div>
    				<?php endif; ?>
    				<div class="row">
    					<div class="<?php if(get_field('skinoptions_content_width', 'options')) : echo get_field('skinoptions_content_width', 'options'); else : echo 'span8 offset2'; endif; ?>">
    						<div class="post-heading">
    							<p><a href="<?php the_permalink(); ?>"><?php echo get_the_date('F d, Y'); ?></a> &middot; <?php comments_popup_link(__('No Comments!', 'semplice'), __('1 comment.', 'semplice'), __('% comments', 'semplice')); ?></p>
    					<h2 class="<?php if(get_field('skinoptions_heading_weight', 'options')) : echo get_field('skinoptions_heading_weight', 'options'); else : echo 'bold'; endif; ?>"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    						</div>
    						<div class="wysiwyg <?php font_sizes(); ?>">
    							<?php the_content(); ?>
    						</div>
    					</div>
    				</div>
    			</div>
    		</section>
    	
    	<?php else : ?>
    		
    		<?php if(get_field('use_semplice') === 'coverslider') {
    			
    			get_template_part('partials/cover_slider'); # include cover slider
    			
    			if(get_field('coverslider_orientation') === 'horizontal' && get_field('content_after_slider')) {
    				$content_slider_id = get_field('content_after_slider');
    				$content_slider_id = $content_slider_id->ID;
    			}
    		
    		} ?>
    		
    		<?php if(get_field('use_semplice') === 'active' || isset($content_slider_id)) : ?>
    			
    			<?php
    				if(isset($content_slider_id)) {
    					$post_id = $content_slider_id;
    				} else {
    					$post_id = get_the_ID();
    				}
    			?>
    
    			<?php if(get_field('cover_visibility') === 'visible' && !isset($content_slider_id)) : ?>
    			<?php get_template_part('partials/fullscreen-cover'); ?>
    			<?php endif; ?>
    			
    			<!-- content fade -->
    			<div class="fade-content">
    				<?php
    					// Remove wpautop
    					remove_filter('the_content', 'wpautop');
    					
    					// get content			
    					$content = get_post_meta( $post_id, 'semplice_ce_content', true );
    
    					// strip out double quotes on bg images
    					$content = remove_esc_bg_quotes($content);
    					
    					// output content
    					$output = apply_filters('the_content', $content);
    
    					echo $output;
    					
    					// reset postdata
    					wp_reset_postdata();
    				?>
    			</div>	
    			
    			<?php if(get_field('share_visibility', $post_id) === 'visible' && get_field('global_share_visbility', 'options') !== 'hidden') : ?>
    				<div class="share-box fade-content">
    					<div class="container">
    						<?php get_template_part('partials/share'); ?>
    					</div>
    				</div>
    			<?php endif; ?>
    		<?php endif; ?>
    	<?php endif; ?>
    <?php } ?>
    <?php get_footer(); # inlude footer ?>
    Moderator bcworkz

    (@bcworkz)

    There’s no syntax errors on that template that I can find. It loads fine as a page template on my site, once the undefined functions (for my site) are dealt with. It doesn’t really work correctly because I don’t have the Semplice theme, but no errors are thrown.

    You should determine why there’s a syntax error on page-home.php at line 25. It’s going to be something silly, like a missing quote ( or too many ), or a missing semicolon, etc. The error could be above line 25. Line 25 is where the parser realized there’s a problem. It’s not always where the error is.

    I’m amused that the theme authors think it’s a WP issue. If it were, there’d be thousands (millions?) of people with the same problem. No doubt WP has plenty of little bugs, but there are no really obvious ones like syntax errors. It may be a conflict with other plugins on your site. If there were a conflict between WP and a theme, by definition the problem is with the theme. Themes are required to not conflict with WP. WP devs will not resolve a conflict with a particular theme in core, the onus is on the theme devs to resolve.

    Thread Starter kvnmcwebn

    (@keeven-even)

    Hi, Thanks for taking a detailed look, that is good to know there are no glaring issues. I will go through the syntax. I did not alter any code on the page though, other than declare a template name. Good idea on checking if it’s a plug in conflict. I’ve actually found a cool plug-in that will allow me to port in svg from external files stored on the server, between that and using custom css on a page by page basis I think I can hack together what I’m looking for, but I’m still going to try and get custom page templates going. Thanks for you help. And yes it’s a shame they said this is a wordpress issue, especially as the theme was over a hundred bucks…

    Moderator bcworkz

    (@bcworkz)

    Sorry, I neglected to answer your initial question:
    “What would the proper way to fork a page.php [be?]”

    Typically, we would create a child theme and place the modified file there. Commercial themes are typically based on a framework, so the theme you bought likely takes up the child position. There is no accommodation for a grandchild theme in WP, so that option is taken away from you. It’s possible to substitute templates from a plugin, but it’s not ideal. A quite a hack if the page template needs to be available in the UI.

    One reason for child themes is it protects your custom work from theme updates. It’s rare in my experience that commercial themes are ever updated. If anything, the framework is updated, not your specific theme, so your modified file is probably safe in the theme folder as long as it has a unique name unlikely to be used in the framework by its devs.

    To be fair about your theme devs, they know their themes work on their end and for virtually all of their customers, so the problem “couldn’t be us, it must be WP”, where “WP” would include whatever plugins and server quirks you may have. Still, their lazy, non-specific response to a paying customer is disappointing. I’m sorry you’re the victim.

    Generally speaking, a plugin could cause errors to occur on theme files since they all interact with WP through filter and action hooks. The exception would be syntax errors. It’s quite odd that page would have an error, it must have been OK at some point. Maybe it was accidentally altered when it happened to be open just for viewing? I’ve done that myself a few times. Can you get the original file from a .zip archive? If not, I’m willing to give it a look and see if I can find the problem.

    [puts moderator hat on] When posting large code blocks, please use Pastebin or a Gist, they make code much easier to read. Especially if you enable syntax highlighting. ```php in Gist, pick the language when saving in pastebin. Third party code posting is actually a Forum Guidelines requirement anyway ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘page template code crashing page’ is closed to new replies.