Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack with HeadLink helper #23

Open
weierophinney opened this issue Dec 31, 2019 · 0 comments
Open

Stack with HeadLink helper #23

weierophinney opened this issue Dec 31, 2019 · 0 comments

Comments

@weierophinney
Copy link
Member

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7623
User: @EugeneVdovenko
Created On: 2015-09-08T18:39:51Z
Updated At: 2015-11-06T22:21:01Z
Body
I write:

$this->headLink()->offsetSetStylesheet(5, "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css");
$this->headLink()->offsetSetStylesheet(6, "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css");

and I have:

object(Zend\View\Helper\Placeholder\Container)#2542 (8) {
...
  ["storage":"ArrayObject":private] => array(2) {
    [5] => object(stdClass)#2606 (5) {
      ["rel"] => string(10) "stylesheet"
      ["type"] => string(8) "text/css"
      ["href"] => string(69) "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"
      ["media"] => string(6) "screen"
      ["conditionalStylesheet"] => bool(false)
    }
    [6] => object(stdClass)#2610 (5) {
      ["rel"] => string(10) "stylesheet"
      ["type"] => string(8) "text/css"
      ["href"] => string(75) "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"
      ["media"] => string(6) "screen"
      ["conditionalStylesheet"] => bool(false)
    }
  }
}

Then, I add

$this->headLink()->offsetSetStylesheet(5, "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css");
$this->headLink()->offsetSetStylesheet(6, "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css");
echo $this->headLink(array('rel' => 'icon', 'href' => 'favicon.ico', 'type' => 'image/x-icon'), 'PREPEND');

and I have now:

object(Zend\View\Helper\Placeholder\Container)#2542 (8) {
...
  ["storage":"ArrayObject":private] => array(3) {
    [0] => object(stdClass)#2608 (3) {
      ["rel"] => string(4) "icon"
      ["href"] => string(11) "favicon.ico"
      ["type"] => string(12) "image/x-icon"
    }
    [1] => object(stdClass)#2606 (5) {
      ["rel"] => string(10) "stylesheet"
      ["type"] => string(8) "text/css"
      ["href"] => string(69) "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"
      ["media"] => string(6) "screen"
      ["conditionalStylesheet"] => bool(false)
    }
    [2] => object(stdClass)#2610 (5) {
      ["rel"] => string(10) "stylesheet"
      ["type"] => string(8) "text/css"
      ["href"] => string(75) "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"
      ["media"] => string(6) "screen"
      ["conditionalStylesheet"] => bool(false)
    }
  }
}

I see, that index change.
If I have some link in layout and some link in view - in result I have wrong order


Comment

User: @vrkansagara
Created On: 2015-09-14T14:12:54Z
Updated At: 2015-09-14T14:12:54Z
Body
Have you looked into documentation?

It's well written there.

You can also take a reference from skeleton application if you like so.

This will help you much better.


Comment

User: @EugeneVdovenko
Created On: 2015-09-14T14:51:35Z
Updated At: 2015-09-14T14:51:35Z
Body
Give me link, plz. I don't saw it's into doc


Comment

User: @vrkansagara
Created On: 2015-09-14T15:34:48Z
Updated At: 2015-09-14T15:34:48Z
Body
http://framework.zend.com/manual/current/en/modules/zend.view.helpers.head-link.html


Comment

User: @EugeneVdovenko
Created On: 2015-09-14T16:47:26Z
Updated At: 2015-09-14T16:47:26Z
Body
I don't see anyway.

I may have written incorrectly, and may translate incorrectly.

But I think why there is a offset()-method if after configure stack and a parameter is passed to __invoke()-method all indexes reset at stack?


Comment

User: @Xerkus
Created On: 2015-09-16T10:14:50Z
Updated At: 2015-09-16T10:14:50Z
Body
You use prepend, that resets indexes. See:
https://github.com/zendframework/zend-view/blob/master/src/Helper/Placeholder/Container/AbstractContainer.php#L268

I can't say if it is bug or expected behavior.


Comment

User: @EugeneVdovenko
Created On: 2015-09-19T09:51:00Z
Updated At: 2015-09-19T10:31:50Z
Body
I think that

  1. Sort the existing rules
  2. Add a new rule
    its right way.

When, I add with priority #1 and #2 at layout, #4 and #5 in view-file I have in stack

  [4] => rule4view
  [5] => rule5view
  [1] => rule1layout
  [2] => rule2layout

and before the output this stack is sorted by index.

But, if I add rule
$this->headLink();
after I have

  [0] => rule
  [1] => rule4view
  [2] => rule5view
  [3] => rule1layout
  [4] => rule2layout

and all my frontend is not displayed correctly because the files are included in the wrong order.

I say its bug.


Comment

User: @Ocramius
Created On: 2015-09-19T10:31:38Z
Updated At: 2015-09-19T10:31:38Z
Body
Please don't use #1 and such, as they have very specific meaning in github (issue linking)



Originally posted by @GeeH at zendframework/zend-view#73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant