Passing variable to Octobercms blogPosts componentPassing variable to Octobercms blogPosts component using a Repeater markupSecure hash and salt for PHP passwordsReference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Reference - What does this error mean in PHP?Rendering a component partial from code in OctoberCMSCan templates be nested in OctoberCMS?OctoberCMS -> Access to a different Pages->Content TabCan i pass php variables when including a partial?Passing ViewBag Variable to ComponentOctoberCMS - Overridden Blog Component (Rainlab Blog) Multiple Usage in Same Page
Is there a specific way to describe over-grown, old, tough vegetables?
How do you say "to hell with everything" in French?
Chandrayaan 2: Why is Vikram Lander's life limited to 14 Days?
What is this sticking out of my wall?
Yet another calculator problem
What makes things real?
A PEMDAS issue request for explanation
How is lower/no gravity simulated on a planet with gravity, without leaving the surface?
If every star in the universe except the Sun were destroyed, would we die?
Distinguishing between octahedral and tetrahedral holes
How there are 3 possible tautomers of 2,2,4-trimethylheptane-3,5-dione?
Was Robin Hood's point of view ethically sound?
How to capture c-lightining logs?
Why can linguists decide which use of language is correct and which is not?
I multiply the source, you (probably) multiply the output!
How would two worlds first establish an exchange rate between their currencies
Need help to understand the integral rules used solving the convolution of two functions
When does order matter in probability?
Why does low tire pressure decrease fuel economy?
RANK used in 'where' returns invalid column, but exists in results set
Gap in tcolorbox after title
Why is it that I have to play this note on the piano as A sharp?
How can faith be maintained in a world of living gods?
The pirate treasure of Leatherback Atoll
Passing variable to Octobercms blogPosts component
Passing variable to Octobercms blogPosts component using a Repeater markupSecure hash and salt for PHP passwordsReference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Reference - What does this error mean in PHP?Rendering a component partial from code in OctoberCMSCan templates be nested in OctoberCMS?OctoberCMS -> Access to a different Pages->Content TabCan i pass php variables when including a partial?Passing ViewBag Variable to ComponentOctoberCMS - Overridden Blog Component (Rainlab Blog) Multiple Usage in Same Page
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
On Octobercms blogPosts component i want to pass a variable. I want to change postsPerPage value using:
variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable
on static layout. So i want to be able to change postsPerPage component value with this field on static Pages.
I use a partial with blogPosts component. On component postsPerPage field i insert the variable.
postsPerPage = " blog_postnumber "
Then i try to insert a number in my field on my static page but is not working. Any idea on how can i pass variables on component?
php laravel twig octobercms
|
show 2 more comments
On Octobercms blogPosts component i want to pass a variable. I want to change postsPerPage value using:
variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable
on static layout. So i want to be able to change postsPerPage component value with this field on static Pages.
I use a partial with blogPosts component. On component postsPerPage field i insert the variable.
postsPerPage = " blog_postnumber "
Then i try to insert a number in my field on my static page but is not working. Any idea on how can i pass variables on component?
php laravel twig octobercms
where this field is renderedblog_postnumber
can you share details
– Hardik Satasiya
Mar 26 at 6:21
I render this field on static layout.htm using variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable. I want to be able to change postsPerPage component value using the this field on my static Pages
– Haral
Mar 26 at 11:23
1
I edited my post to make more clear what I want to achieve.
– Haral
Mar 26 at 20:22
ok and where do you include yourblogPosts
component can you also share that detail
– Hardik Satasiya
Mar 27 at 16:58
I use a partial with blogPosts component. Inside that partial i want to be able to pass variables on component.
– Haral
Mar 27 at 18:55
|
show 2 more comments
On Octobercms blogPosts component i want to pass a variable. I want to change postsPerPage value using:
variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable
on static layout. So i want to be able to change postsPerPage component value with this field on static Pages.
I use a partial with blogPosts component. On component postsPerPage field i insert the variable.
postsPerPage = " blog_postnumber "
Then i try to insert a number in my field on my static page but is not working. Any idea on how can i pass variables on component?
php laravel twig octobercms
On Octobercms blogPosts component i want to pass a variable. I want to change postsPerPage value using:
variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable
on static layout. So i want to be able to change postsPerPage component value with this field on static Pages.
I use a partial with blogPosts component. On component postsPerPage field i insert the variable.
postsPerPage = " blog_postnumber "
Then i try to insert a number in my field on my static page but is not working. Any idea on how can i pass variables on component?
php laravel twig octobercms
php laravel twig octobercms
edited Mar 26 at 20:20
Haral
asked Mar 25 at 23:26
HaralHaral
533 silver badges9 bronze badges
533 silver badges9 bronze badges
where this field is renderedblog_postnumber
can you share details
– Hardik Satasiya
Mar 26 at 6:21
I render this field on static layout.htm using variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable. I want to be able to change postsPerPage component value using the this field on my static Pages
– Haral
Mar 26 at 11:23
1
I edited my post to make more clear what I want to achieve.
– Haral
Mar 26 at 20:22
ok and where do you include yourblogPosts
component can you also share that detail
– Hardik Satasiya
Mar 27 at 16:58
I use a partial with blogPosts component. Inside that partial i want to be able to pass variables on component.
– Haral
Mar 27 at 18:55
|
show 2 more comments
where this field is renderedblog_postnumber
can you share details
– Hardik Satasiya
Mar 26 at 6:21
I render this field on static layout.htm using variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable. I want to be able to change postsPerPage component value using the this field on my static Pages
– Haral
Mar 26 at 11:23
1
I edited my post to make more clear what I want to achieve.
– Haral
Mar 26 at 20:22
ok and where do you include yourblogPosts
component can you also share that detail
– Hardik Satasiya
Mar 27 at 16:58
I use a partial with blogPosts component. Inside that partial i want to be able to pass variables on component.
– Haral
Mar 27 at 18:55
where this field is rendered
blog_postnumber
can you share details– Hardik Satasiya
Mar 26 at 6:21
where this field is rendered
blog_postnumber
can you share details– Hardik Satasiya
Mar 26 at 6:21
I render this field on static layout.htm using variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable. I want to be able to change postsPerPage component value using the this field on my static Pages
– Haral
Mar 26 at 11:23
I render this field on static layout.htm using variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable. I want to be able to change postsPerPage component value using the this field on my static Pages
– Haral
Mar 26 at 11:23
1
1
I edited my post to make more clear what I want to achieve.
– Haral
Mar 26 at 20:22
I edited my post to make more clear what I want to achieve.
– Haral
Mar 26 at 20:22
ok and where do you include your
blogPosts
component can you also share that detail– Hardik Satasiya
Mar 27 at 16:58
ok and where do you include your
blogPosts
component can you also share that detail– Hardik Satasiya
Mar 27 at 16:58
I use a partial with blogPosts component. Inside that partial i want to be able to pass variables on component.
– Haral
Mar 27 at 18:55
I use a partial with blogPosts component. Inside that partial i want to be able to pass variables on component.
– Haral
Mar 27 at 18:55
|
show 2 more comments
1 Answer
1
active
oldest
votes
Its really tricky that your passed variable/property to component will be used or not
if that property is fetched in component's onRender
method it will be used, if its used on onRun
then it will not be used. ( its OctoberCMS Design )
for
blogPosts
component its inonRun
so when you pass property like this% component 'blogPosts' postsPerPage="2" %
it will not be used, But To handle this we need other work-around
(1) for the component
blogPosts
you included in partial you need to use property from param. check screen shot.
(2) In you Static layout's Code section you need to add this code
public function onStart()
$statiPage = $this->page->apiBag['staticPage'];
// default posts per page
$defaultBlogPost = 5;
if(isset($statiPage->viewBag['blog_postnumber']))
// fetching value from the page field
$defaultBlogPost = intVal($statiPage->viewBag['blog_postnumber']);
$router = $this->getRouter();
// combine with existing params
$router->setParameters(['myBlogPerPage' => $defaultBlogPost] + $router->getParameters());
And in markup part field
variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable
(3) Now you can start using it set variable value we set it by default 5 in code section, to override it specify value in page's postnumber field section
It will start working.
If any doubts please comment.
1
Hardik Thank you for this Excellent Tutorial! When i use {variable ..../variable markup everything is working fine. Do you know how can i make te same using repeater groups? using repeater name="sections" groups="~/themes/..../fields.yaml" tab="Fields"/repeater markup?
– Haral
Mar 28 at 18:07
if you use repeater you will get multiple values so how do we find you need which value, still if you can usedd($statiPage->viewBag);
in code section where we used$defaultBlogPost
just dump output and you can check values and use values accordingly.
– Hardik Satasiya
Mar 29 at 8:35
still if you face issue please create new question explaining how you wan to use that repeater field values and what are fields etc.. so i can assist you more.
– Hardik Satasiya
Mar 29 at 8:36
Thank you Hardik. I created other question here: stackoverflow.com/questions/55421938/…
– Haral
Mar 29 at 16:42
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347814%2fpassing-variable-to-octobercms-blogposts-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Its really tricky that your passed variable/property to component will be used or not
if that property is fetched in component's onRender
method it will be used, if its used on onRun
then it will not be used. ( its OctoberCMS Design )
for
blogPosts
component its inonRun
so when you pass property like this% component 'blogPosts' postsPerPage="2" %
it will not be used, But To handle this we need other work-around
(1) for the component
blogPosts
you included in partial you need to use property from param. check screen shot.
(2) In you Static layout's Code section you need to add this code
public function onStart()
$statiPage = $this->page->apiBag['staticPage'];
// default posts per page
$defaultBlogPost = 5;
if(isset($statiPage->viewBag['blog_postnumber']))
// fetching value from the page field
$defaultBlogPost = intVal($statiPage->viewBag['blog_postnumber']);
$router = $this->getRouter();
// combine with existing params
$router->setParameters(['myBlogPerPage' => $defaultBlogPost] + $router->getParameters());
And in markup part field
variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable
(3) Now you can start using it set variable value we set it by default 5 in code section, to override it specify value in page's postnumber field section
It will start working.
If any doubts please comment.
1
Hardik Thank you for this Excellent Tutorial! When i use {variable ..../variable markup everything is working fine. Do you know how can i make te same using repeater groups? using repeater name="sections" groups="~/themes/..../fields.yaml" tab="Fields"/repeater markup?
– Haral
Mar 28 at 18:07
if you use repeater you will get multiple values so how do we find you need which value, still if you can usedd($statiPage->viewBag);
in code section where we used$defaultBlogPost
just dump output and you can check values and use values accordingly.
– Hardik Satasiya
Mar 29 at 8:35
still if you face issue please create new question explaining how you wan to use that repeater field values and what are fields etc.. so i can assist you more.
– Hardik Satasiya
Mar 29 at 8:36
Thank you Hardik. I created other question here: stackoverflow.com/questions/55421938/…
– Haral
Mar 29 at 16:42
add a comment |
Its really tricky that your passed variable/property to component will be used or not
if that property is fetched in component's onRender
method it will be used, if its used on onRun
then it will not be used. ( its OctoberCMS Design )
for
blogPosts
component its inonRun
so when you pass property like this% component 'blogPosts' postsPerPage="2" %
it will not be used, But To handle this we need other work-around
(1) for the component
blogPosts
you included in partial you need to use property from param. check screen shot.
(2) In you Static layout's Code section you need to add this code
public function onStart()
$statiPage = $this->page->apiBag['staticPage'];
// default posts per page
$defaultBlogPost = 5;
if(isset($statiPage->viewBag['blog_postnumber']))
// fetching value from the page field
$defaultBlogPost = intVal($statiPage->viewBag['blog_postnumber']);
$router = $this->getRouter();
// combine with existing params
$router->setParameters(['myBlogPerPage' => $defaultBlogPost] + $router->getParameters());
And in markup part field
variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable
(3) Now you can start using it set variable value we set it by default 5 in code section, to override it specify value in page's postnumber field section
It will start working.
If any doubts please comment.
1
Hardik Thank you for this Excellent Tutorial! When i use {variable ..../variable markup everything is working fine. Do you know how can i make te same using repeater groups? using repeater name="sections" groups="~/themes/..../fields.yaml" tab="Fields"/repeater markup?
– Haral
Mar 28 at 18:07
if you use repeater you will get multiple values so how do we find you need which value, still if you can usedd($statiPage->viewBag);
in code section where we used$defaultBlogPost
just dump output and you can check values and use values accordingly.
– Hardik Satasiya
Mar 29 at 8:35
still if you face issue please create new question explaining how you wan to use that repeater field values and what are fields etc.. so i can assist you more.
– Hardik Satasiya
Mar 29 at 8:36
Thank you Hardik. I created other question here: stackoverflow.com/questions/55421938/…
– Haral
Mar 29 at 16:42
add a comment |
Its really tricky that your passed variable/property to component will be used or not
if that property is fetched in component's onRender
method it will be used, if its used on onRun
then it will not be used. ( its OctoberCMS Design )
for
blogPosts
component its inonRun
so when you pass property like this% component 'blogPosts' postsPerPage="2" %
it will not be used, But To handle this we need other work-around
(1) for the component
blogPosts
you included in partial you need to use property from param. check screen shot.
(2) In you Static layout's Code section you need to add this code
public function onStart()
$statiPage = $this->page->apiBag['staticPage'];
// default posts per page
$defaultBlogPost = 5;
if(isset($statiPage->viewBag['blog_postnumber']))
// fetching value from the page field
$defaultBlogPost = intVal($statiPage->viewBag['blog_postnumber']);
$router = $this->getRouter();
// combine with existing params
$router->setParameters(['myBlogPerPage' => $defaultBlogPost] + $router->getParameters());
And in markup part field
variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable
(3) Now you can start using it set variable value we set it by default 5 in code section, to override it specify value in page's postnumber field section
It will start working.
If any doubts please comment.
Its really tricky that your passed variable/property to component will be used or not
if that property is fetched in component's onRender
method it will be used, if its used on onRun
then it will not be used. ( its OctoberCMS Design )
for
blogPosts
component its inonRun
so when you pass property like this% component 'blogPosts' postsPerPage="2" %
it will not be used, But To handle this we need other work-around
(1) for the component
blogPosts
you included in partial you need to use property from param. check screen shot.
(2) In you Static layout's Code section you need to add this code
public function onStart()
$statiPage = $this->page->apiBag['staticPage'];
// default posts per page
$defaultBlogPost = 5;
if(isset($statiPage->viewBag['blog_postnumber']))
// fetching value from the page field
$defaultBlogPost = intVal($statiPage->viewBag['blog_postnumber']);
$router = $this->getRouter();
// combine with existing params
$router->setParameters(['myBlogPerPage' => $defaultBlogPost] + $router->getParameters());
And in markup part field
variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable
(3) Now you can start using it set variable value we set it by default 5 in code section, to override it specify value in page's postnumber field section
It will start working.
If any doubts please comment.
answered Mar 28 at 7:35
Hardik SatasiyaHardik Satasiya
5,6671 gold badge12 silver badges26 bronze badges
5,6671 gold badge12 silver badges26 bronze badges
1
Hardik Thank you for this Excellent Tutorial! When i use {variable ..../variable markup everything is working fine. Do you know how can i make te same using repeater groups? using repeater name="sections" groups="~/themes/..../fields.yaml" tab="Fields"/repeater markup?
– Haral
Mar 28 at 18:07
if you use repeater you will get multiple values so how do we find you need which value, still if you can usedd($statiPage->viewBag);
in code section where we used$defaultBlogPost
just dump output and you can check values and use values accordingly.
– Hardik Satasiya
Mar 29 at 8:35
still if you face issue please create new question explaining how you wan to use that repeater field values and what are fields etc.. so i can assist you more.
– Hardik Satasiya
Mar 29 at 8:36
Thank you Hardik. I created other question here: stackoverflow.com/questions/55421938/…
– Haral
Mar 29 at 16:42
add a comment |
1
Hardik Thank you for this Excellent Tutorial! When i use {variable ..../variable markup everything is working fine. Do you know how can i make te same using repeater groups? using repeater name="sections" groups="~/themes/..../fields.yaml" tab="Fields"/repeater markup?
– Haral
Mar 28 at 18:07
if you use repeater you will get multiple values so how do we find you need which value, still if you can usedd($statiPage->viewBag);
in code section where we used$defaultBlogPost
just dump output and you can check values and use values accordingly.
– Hardik Satasiya
Mar 29 at 8:35
still if you face issue please create new question explaining how you wan to use that repeater field values and what are fields etc.. so i can assist you more.
– Hardik Satasiya
Mar 29 at 8:36
Thank you Hardik. I created other question here: stackoverflow.com/questions/55421938/…
– Haral
Mar 29 at 16:42
1
1
Hardik Thank you for this Excellent Tutorial! When i use {variable ..../variable markup everything is working fine. Do you know how can i make te same using repeater groups? using repeater name="sections" groups="~/themes/..../fields.yaml" tab="Fields"/repeater markup?
– Haral
Mar 28 at 18:07
Hardik Thank you for this Excellent Tutorial! When i use {variable ..../variable markup everything is working fine. Do you know how can i make te same using repeater groups? using repeater name="sections" groups="~/themes/..../fields.yaml" tab="Fields"/repeater markup?
– Haral
Mar 28 at 18:07
if you use repeater you will get multiple values so how do we find you need which value, still if you can use
dd($statiPage->viewBag);
in code section where we used $defaultBlogPost
just dump output and you can check values and use values accordingly.– Hardik Satasiya
Mar 29 at 8:35
if you use repeater you will get multiple values so how do we find you need which value, still if you can use
dd($statiPage->viewBag);
in code section where we used $defaultBlogPost
just dump output and you can check values and use values accordingly.– Hardik Satasiya
Mar 29 at 8:35
still if you face issue please create new question explaining how you wan to use that repeater field values and what are fields etc.. so i can assist you more.
– Hardik Satasiya
Mar 29 at 8:36
still if you face issue please create new question explaining how you wan to use that repeater field values and what are fields etc.. so i can assist you more.
– Hardik Satasiya
Mar 29 at 8:36
Thank you Hardik. I created other question here: stackoverflow.com/questions/55421938/…
– Haral
Mar 29 at 16:42
Thank you Hardik. I created other question here: stackoverflow.com/questions/55421938/…
– Haral
Mar 29 at 16:42
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347814%2fpassing-variable-to-octobercms-blogposts-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
where this field is rendered
blog_postnumber
can you share details– Hardik Satasiya
Mar 26 at 6:21
I render this field on static layout.htm using variable name="blog_postnumber" label="postnumber" tab="postnumber" type="number"/variable. I want to be able to change postsPerPage component value using the this field on my static Pages
– Haral
Mar 26 at 11:23
1
I edited my post to make more clear what I want to achieve.
– Haral
Mar 26 at 20:22
ok and where do you include your
blogPosts
component can you also share that detail– Hardik Satasiya
Mar 27 at 16:58
I use a partial with blogPosts component. Inside that partial i want to be able to pass variables on component.
– Haral
Mar 27 at 18:55