Cannot use hook to remove products from homepage - spree

I'm trying to use deface to remove the product list on the home page of a new Spree theme.
I have the following override (overrides/remove_products.rb):
Deface::Override.new(:virtual_path => "spree/layouts/spree_application",
:remove => "[data-hook='homepage_products']",
:name => "remove_products")
The override doesn't appear to run. I'm assuming that the virtual path may be incorrect? I have other overrides working (to remove the sidebar on the homepage for example).

I believe the file you are looking for is core/app/views/spree/home/index.html.erb, so I believe your virtual path should be:
spree/home/index

Example: Remove left Nav bar from Spree index page.
Step 1: create a file with name in app/overides/remove_left_nav_bar.rb
Step 2: paste following code in it.
Deface::Override.new(:virtual_path => 'spree/home/index',
:name => 'remove_left_nav_bar',
:remove => "[data-hook='homepage_sidebar_navigation']"
)
step 3: Restart your server.

Related

Where is location of renderView function that used in Opencart Journal 3 theme Quick Checkout controller

I am trying to auto add a specific product to cart when visitors added an other specific product to cart on Opencart 3.0.2.0 and Journal 3 theme in Quick Checkout.
I could do it in cart.twig but I couldn't do it in Quick Checkout because I can't find where is renderView function that rendering cart_block in checkout controller.
Related code is bellow;
This code from catalog>controller>journal3>checkout.php.
From line 204 to 215.
$data['cart_block'] = $this->renderView('journal3/checkout/cart', array(
'column_image' => $this->language->get('column_image'),
'column_name' => $this->language->get('column_name'),
'column_model' => $this->language->get('column_model'),
'column_quantity' => $this->language->get('column_quantity'),
'column_price' => $this->language->get('column_price'),
'column_total' => $this->language->get('column_total'),
'text_recurring_item' => $this->language->get('text_recurring_item'),
'button_update' => $this->language->get('button_update'),
'button_remove' => $this->language->get('button_remove'),
'error_warning' => $this->language->get('error_stock'),
));
One simple but not optimal solution can be like this:
Go to catalog/controller/checkout/cart.php, find the add method public function add() { then in that add method find the following line of code:
$this->cart->add($this->request->post['product_id'], $quantity, $option, $recurring_id);
Just below that line of code, you can add the following line of code:
if($this->request->post['product_id'] ==43){
$this->cart->add('28',1);
}
** Please make changes as per your requirement. The above code means if product id 43 is added then product id 28 gets added automatically, but keep in mind if someone adds two 43 then there will be two 28 products.

Get name of next doctrine migration

How could I get the name / version of the next migration to execute? Something similar to migrations:latest but more like migrations:next. I need this as input to another command so it needs to be parseable output (can't really just use migrations:status).
You can use the Configuration object of the Doctrine migrations bundle. This is even (somewhat) documented as custom configuration.
Here is a minimal code example that works for me:
public function migrationVersionAction(EntityManagerInterface $em, ParameterBagInterface $parameters) {
$connection = $em->getConnection();
$configuration = new \Doctrine\Migrations\Configuration\Configuration($connection);
$configuration->setMigrationsNamespace($parameters->get('doctrine_migrations.namespace'));
$configuration->setMigrationsDirectory($parameters->get('doctrine_migrations.dir_name'));
$configuration->setMigrationsTableName($parameters->get('doctrine_migrations.table_name'));
return new JsonResponse([
'prev' => $configuration->resolveVersionAlias('prev'),
'current' => $configuration->resolveVersionAlias('current'),
'next' => $configuration->resolveVersionAlias('next'),
'latest' => $configuration->resolveVersionAlias('latest')
]);
}
You might want to set the remaining parameters as well though, especially if they differ from the defaults. For this, the configuration documentation might help in addition to the link above.

Oracle APEX how do I populate cascading select lists without page submit

I have an APEX page with a few select lists, using collections to save and refresh the page. The "System" select list is dependent upon the "Brand" selected value. I have the page working how I want, but it requires the page to be submitted after a "Brand" value is chosen so that the "System" lov is properly populated.
I am trying to make it so that when the "Brand" value is changed or selected, the "System" lov is changed immediately without needing a page submit. I've been reading and it seems you need to use jQuery and AJAX callback, but I just cannot get my head around that and make any progress.
Hoping someone can help me. I am certainly a rookie with web coding in general.
Added: my local APEX version is 5.0.3.
https://apex.oracle.com/pls/apex/f?p=4550
Workspace: UNCLE_BUCK_WS
User: developer1
Pwd: developer1
Application 83513 - Tooth Selector
Page 5: Page that works using submit page
Page 6: Page I started trying to use jQuery, but did not get very far
Added:
There is no cascading LOV for manual tabular form. See my region definition below. Hoping someone can still help, maybe copy my page and make the required changes.
select apex_item.select_list_from_query(p_idx => 1,
p_value => n001,
p_query => 'SELECT tooth_number display_value, tooth_number return_value FROM psp_teeth WHERE tooth_numbering_method = :P5_TOOTH_NUMBER_METHOD
ORDER BY tooth_number',
p_null_text => '- Choose Tooth -')
|| apex_item.hidden(p_idx => 50, p_value => seq_id) Tooth_Number
, apex_item.select_list_from_lov(p_idx => 10, p_value => c001, p_lov => 'BRAND', p_null_text => '- Choose Brand -') brand
, apex_item.select_list_from_lov(p_idx => 12, p_value => c002, p_lov => 'TYPE', p_null_text => '- Choose Type -') type
, apex_item.select_list (p_idx => 14,
p_value => c003,
p_list_values => CASE c001
WHEN 'BRAND_A' THEN 'SYSTEM_A1,SYSTEM_A2'
WHEN 'BRAND_B' THEN 'SYSTEM_B1,SYSTEM_B2'
END,
p_show_null => 'YES',
p_null_text => '- Choose System -') system
, apex_item.checkbox2(p_idx => 16, p_value => seq_id, p_checked_values => CASE c004 WHEN '1' THEN seq_id END) delete_row
from apex_collections
where collection_name = 'TEMPCOL'
Don't use tabular forms, they are archaic! Use an Interactive Grid instead, which supports cascading LOVs declaratively (you don't need to write any code, just specify that column TYPE cascades from column BRAND):
See page 9 in your app where I have created one (I didn't bother creating the master region). My LOV definition for TYPE is a bit cumbersome, you may be able to improve on that (i.e. get back to the "dynamic static" LOV that you had before).

serve static views from subdirs using a single controller in rails 4

If have some static pages in a tree structure. The ones at the first level are served using static_pages_controller.rb and in my routes.rb I have :
get '/static_pages/news' , :to => 'static_pages#news' , :as => 'news'
get '/static_pages/index' , :to => 'static_pages#index' , :as => 'index'
....
The above exist in
app\views\static_pages\news.html.erb
app\views\static_pages\index.html.erb
....
Now, I pasted some other static pages underneath the static_pages root:
app\views\static_pages\ermis\news.html.erb
app\views\static_pages\ermis\index.html.erb
....
I added in routes.rb this:
get '/static_pages/ermis/news' , :to => 'static_pages#news' , :as => 'news'
get '/static_pages/ermis/index' , :to => 'static_pages#index' , :as => 'index'
The above doesnt work because the actions already exist (parent folders). So I went the painful step of renaming the files to (there must be a better way though?!?)
app\views\static_pages\ermis\ermisnews.html.erb
app\views\static_pages\ermis\ermisindex.html.erb
....
and my routes.rb became
get '/static_pages/ermis/news' , :to => 'static_pages#ermisnews' , :as => 'ermisnews'
get '/static_pages/ermis/index', :to => 'static_pages#ermisindex', :as => 'ermisindex'
....
the controller is empty
class StaticPagesController < ApplicationController
end
Why cant the pages be served ? what am I missing?
When I click on
<%= link_to("Ermis", ermisnews_path, class: 'pictureTitle') %>
I get
"The action 'ermisnews' could not be found for StaticPagesController"
Here my routes.rb
Prefix Verb URI Pattern Controller#Action
root GET / static_pages#index
ermisindex GET /static_pages/ermis/index(.:format) static_pages#ermisindex
ermisnews GET /static_pages/ermis/news(.:format) static_pages#ermisnews
news GET /static_pages/news(.:format) static_pages#news
index GET /static_pages/index(.:format) static_pages#index
NOTE: I do not get an error when using link directly pointing to .erb files on static_pages
<%= link_to("News" , news_path , class: 'pictureTitle')
Question:
1) How can I use the same controller to also serve static pages underneath /static_pages eg. /static_pages/ermis
2) Am I obliged to actually rename the files to have them represent unique actions?
In route.rb, change your routes as:
resources :static_pages do
resources :ermis do
get 'ermisnews' , :on => :collection
end
end
match '/ermisnews' => 'static_pages#ermisnews', :as => :news
And then run rake routes.
Eventually I found a solution to my issue:
created the following namespace:
namespace :sp do
resources: ixanos
resources: ermis
end
created the following controllers
class Sp::IxanosController < ApplicationController
end
class Sp::ErmisController < ApplicationController
end
Placed the controllers under app/controllers/sp/
Created the directories app/views/sp/ixanos and app/views/sp/ermis and copied my files in them.
(*) This way I can have as many static pages as I want underneath the given roots (ermis and ixanos). I haven't tested the situation whereby I will have sub-directories like sp/ermis/dir1/dir2 ...

How to generate JavaDoc using buildr?

I want to automatically generate the JavaDoc using buildr. I tried using the approach suggested in the official Guide PDF from the Homepage. However, it did not work.
define "SharedState_ebBP", :layout=>eclipse_layout do
project.version = VERSION_NUMBER
project.group = GROUP
doc :windowtitle => "Abandon All Hope, Ye Who Enter Here", :private => true
end
The error message is as follows:
RuntimeError: Don't know how to generate documentation from windowtitleAbandon ......
The correct syntax for setting the window title is
doc.using(:windowtitle => "Abandon All Hope", :private => true)
and with end on a line by itself. However that in and of itself does not cause the doc task to get run automatically.
To automatically build the JavaDoc when you run buildr simply add to the end of your buildfile:
task :default => [:build, :doc]
This redefines the default task to first build and then doc.