This Question is Answered

1 "correct" answer available (4 pts) 1 "helpful" answer available (2 pts)
2 Replies Last post: Feb 12, 2013 2:26 PM by minesabad  
minesabad Newbie 3 posts since
Oct 3, 2012
Currently Being Moderated

Feb 12, 2013 1:36 PM

Is it possible to specify code style settings for inline PHP or PHTML files?

Hello,

 

I've tried to look in the forum for a similar question but no luck so far.

 

I'm looking for a way to specify code style (indentation, new line policy, etc) settings for PHTML files or HTML with inline PHP code.

 

Let's say I have the following piece of code:

 

<?php if ($this->canEmailToFriend()): ?>
            <p class="email-friend">
        <a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a>
            </p>
          <?php endif; ?>`

 

If I use PHPStorms "Reformat Code" option on the whole file, the text gets reformatted to this:

 

  <?php if ($this->canEmailToFriend()): ?>
<p class="email-friend">
  <a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a>
</p>
  <?php endif; ?>

 

Is there a way to change how PHPStorm applies code style settings on files with inline PHP code?

 

 

Thank you.

Maxim Makhankov JetBrains 71 posts since
May 31, 2012
Currently Being Moderated
Feb 12, 2013 2:20 PM in response to: minesabad
Re: Is it possible to specify code style settings for inline PHP or PHTML files?

What is your PhpStorm version? In the latest EAP build (that includes bugfix of the issue WI-11118) I get the following result:

<?php if ($this->canEmailToFriend()): ?>
    <p class="email-friend">
        <a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a>
    </p>
<?php endif; ?>

Is this what you need?

More Like This

  • Retrieving data ...