質問編集履歴

3

コード追記

2017/07/22 12:00

投稿

holic
holic

スコア134

test CHANGED
File without changes
test CHANGED
@@ -166,37 +166,23 @@
166
166
 
167
167
  {
168
168
 
169
- $bookmarks = $this->paginate($this->Bookmarks);
169
+ $Blogs = $this->paginate($this->Blogs);
170
-
171
-
172
-
170
+
171
+
172
+
173
- $this->set(compact('bookmarks'));
173
+ $this->set(compact('Blogs'));
174
-
174
+
175
- $this->set('_serialize', ['bookmarks']);
175
+ $this->set('_serialize', ['Blogs']);
176
176
 
177
177
  }
178
178
 
179
179
 
180
180
 
181
- /**
182
-
183
- * View method
184
-
185
- *
186
-
187
- * @param string|null $id Bookmark id.
188
-
189
- * @return \Cake\Http\Response|void
190
-
191
- * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
192
-
193
- */
194
-
195
181
  public function view($id = null)
196
182
 
197
183
  {
198
184
 
199
- $bookmark = $this->Bookmarks->get($id, [
185
+ $Blog = $this->Blogs->get($id, [
200
186
 
201
187
  'contain' => ['Keywords', 'Tags']
202
188
 
@@ -204,9 +190,9 @@
204
190
 
205
191
 
206
192
 
207
- $this->set('bookmark', $bookmark);
193
+ $this->set('blog', $blog);
208
-
194
+
209
- $this->set('_serialize', ['bookmark']);
195
+ $this->set('_serialize', ['blog']);
210
196
 
211
197
  }
212
198
 

2

コード挿入

2017/07/22 12:00

投稿

holic
holic

スコア134

test CHANGED
File without changes
test CHANGED
@@ -142,8 +142,6 @@
142
142
 
143
143
  このようにアソシエーションされた内容を記事一覧ページ
144
144
 
145
- つまり
146
-
147
145
  /test/blogs/
148
146
 
149
147
  をレンダリングさせたときにも表示させたいのです。
@@ -152,7 +150,7 @@
152
150
 
153
151
  blogsテーブルの中身だけの一覧が表示されます、
154
152
 
155
- つまり、idとtitleとdataこれに
153
+ つまり、idとtitleとdataこれにプラスして
156
154
 
157
155
  アソシエーションさせた情報つまり「タグ」「キーワード」情報も表示させたいです。
158
156
 
@@ -160,6 +158,62 @@
160
158
 
161
159
 
162
160
 
161
+ 現在のBlogsController.php(indexとviewの部分)を記します
162
+
163
+ ```php
164
+
165
+ public function index()
166
+
167
+ {
168
+
169
+ $bookmarks = $this->paginate($this->Bookmarks);
170
+
171
+
172
+
173
+ $this->set(compact('bookmarks'));
174
+
175
+ $this->set('_serialize', ['bookmarks']);
176
+
177
+ }
178
+
179
+
180
+
181
+ /**
182
+
183
+ * View method
184
+
185
+ *
186
+
187
+ * @param string|null $id Bookmark id.
188
+
189
+ * @return \Cake\Http\Response|void
190
+
191
+ * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
192
+
193
+ */
194
+
195
+ public function view($id = null)
196
+
197
+ {
198
+
199
+ $bookmark = $this->Bookmarks->get($id, [
200
+
201
+ 'contain' => ['Keywords', 'Tags']
202
+
203
+ ]);
204
+
205
+
206
+
207
+ $this->set('bookmark', $bookmark);
208
+
209
+ $this->set('_serialize', ['bookmark']);
210
+
211
+ }
212
+
213
+ ```
214
+
215
+
216
+
163
217
 
164
218
 
165
219
  ###補足情報(言語/FW/ツール等のバージョンなど)

1

画像差し替え

2017/07/22 11:58

投稿

holic
holic

スコア134

test CHANGED
File without changes
test CHANGED
@@ -136,7 +136,7 @@
136
136
 
137
137
  そして[tags][keywords]テーブルでアソシエーションされた内容も記述されます。
138
138
 
139
- ![イメージ説明](062fddf48b03b00ed26b2e7010d44c99.jpeg)
139
+ ![イメージ説明](2b1dcd04dd68644a6e0e2353c286f2b6.jpeg)
140
140
 
141
141
 
142
142